koa2-note
koa2-note copied to clipboard
static-server的例子中,读取文件内容的编码不能写死为binary哦
在 /demo/static-server/util/file.js
里面有这样的一段代码 :
let content = fs.readFileSync(filePath, 'binary' )
其实,这里需要对文件类型进行判断的,因为中文使用 binary
读取出来会是乱码的。个人觉得只有是图片、视频等才有必要使用 binary
读取。其他的用 utf8
便可。