browser-sync - Lite Server 热重载不适用于默认配置
问题描述
对我的 index.html 文件进行更改后,Lite Server 不会重新加载页面。
我没有使用 bs-config.json 文件。使用以下命令启动 lite 服务器时,我的 index.html 在新选项卡中正确打开:
npm run dev
此控制台信息可能会有所帮助:
> lite@1.0.0 dev C:\test\lite
> lite-server
Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
** browser-sync config **
{ injectChanges: false,
files: [ './**/*.{html,htm,css,js}' ],
watchOptions: { ignored: 'node_modules' },
server: { baseDir: './', middleware: [ [Function], [Function] ] } }
[Browsersync] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://192.168.1.39:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-------------------------------------
[Browsersync] Serving files from: ./
[Browsersync] Watching files...
19.07.26 21:02:27 304 GET /index.html
[Browsersync] Reloading Browsers...
更改和保存我的 index.html 时,
[BrowserSync] 'Reloading Browsers'
出现在我的控制台中,但我的页面没有重新加载。我需要按 F5 然后
19.07.26 21:09:32 200 GET /index.html
出现在我的控制台中。
包.json:
{
"name": "lite",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "lite-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.5.3"
}
}
如何让 Lite Server 热重载我的页面?
解决方案
我找到了解决方案
“浏览器同步”仅在有标签“正文”时才有效
只需在您的html页面中添加body标签
推荐阅读
- json - 如何根据 Postman 中的 json 响应设置全局变量
- python-3.x - 即使在浏览器关闭并加载到上一页后,如何在 FLASK 中保留进程?
- javascript - 谁能建议一种通过对象键对对象数组进行分组的方法,然后根据 JavaScript 中的分组创建一个新的对象数组?
- java - 如何在android中使用lambda表达式?
- python - 使用列表中的值作为索引值来创建新的多维数组
- mysql - 哪种运输方式的延迟订单数量最多
- excel - 加载带有换行符的 CSV
- c++ - 如果我们从派生类的指针中调用一个成员函数,该指针指向基础对象怎么办?
- python - 我有一个 DataFrame,需要在列之间执行计算。我的函数 do_something 可以向量化吗?
- flutter - 如何使用 streamController 来 Flutter 推送通知?