Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue] 在使用vue-cli开发vue项目时,自动刷新页面的原理你了解吗? #541

Open
haizhilin2013 opened this issue Jul 2, 2019 · 2 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] 在使用vue-cli开发vue项目时,自动刷新页面的原理你了解吗?

@haizhilin2013 haizhilin2013 added the vue vue label Jul 2, 2019
@sky124380729
Copy link

我觉得应该是使用了webpack-dev的热重载模块,热重载的原理应该是socket,再具体一点就母鸡了

@ajh99990
Copy link

ajh99990 commented Dec 3, 2019

自动刷新页面并不是vue-cli的功能,而是webpack的hot-module-replacement-plugin插件在做这件事,这个插件是webpack自带的插件,用来做hmr的。如果需要配置hmr只需要在webpack.config.js的devServer字段写 下面的配置即可。
{
contentBase: 服务器可以访问的根目录,
hot:true, //开启热模块替换也就是hmr
hotOnly:true //不刷新页面,只做hmr
}
而由于vue-cli3集成了webpack的配置,所以vue.config.js里面也有这个属性,配置写法是一样的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

3 participants