1、关于ws中自动保存和egg自动重启的冲突
1)、ws中的自动保存egg识别不到,需要把这个自动保存关闭掉
方法:file settings 把红框中的所有的对号都去掉
![](https://img.haomeiwen.com/i10562667/d81655ab1aabf915.png)
2、设置服务器启动端口
方法: package.json scripts "dev": "egg-bin dev --port 80",
3、在页面动态写入js的时候问题
前端代码:
<script> document.write('<script src="./config.js?v=' + Math.random() +'">xxx </script>')</script>
egg代码:
let contents= fs.readFileSync('app/config.js');
this.ctx.set('content-type', 'application/x-javascript'); //设置正确的文件类型才能用,因为egg自动设置了文件类型检测的头x-content-type-options:nosniff
this.ctx.body= contents
4、 public 文件夹下不自动识别index.html 需要自己在url上拼上文件名
待续。。。。。
网友评论