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-hot-reload 功能 #1

Open
yinxin630 opened this issue Jul 17, 2018 · 0 comments
Open

如何愉快的用上 vue-hot-reload 功能 #1

yinxin630 opened this issue Jul 17, 2018 · 0 comments
Labels

Comments

@yinxin630
Copy link
Owner

vue 的 hot-realod 功能是由 vue-hot-reload-api 实现的
vue-loader 集成了它, 可以通过参数 options.hotReload = true 来启用

但是有些情况下, 页面不会正确的 hot-reload, 下面记录各个问题的解决办法

问题一: TypeError: Cannot read property 'extend' of undefined

该问题是由于渲染顶层组件的方式不正确

错误的挂载方式

window.app = new Vue(Index).$mount('#app');

正确的挂载方式

window.app = new Vue({
    render: h => h(Index),
}).$mount('#app');

参考: vuejs/vue-hot-reload-api#61

问题二: [Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined"

该问题是由于挂载 vue-router 的方式不正确

错误的挂载方式

const router = new Router();
Index.router = router;
window.app = new Vue({
    render: h => h(Index),
}).$mount('#app');

正确的挂载方式

const router = new Router();
window.app = new Vue({
    render: h => h(Index),
    router,
}).$mount('#app');
@yinxin630 yinxin630 added the vue label Jul 17, 2018
@yinxin630 yinxin630 reopened this Jul 17, 2018
ChuanyuWang pushed a commit to ChuanyuWang/test that referenced this issue Apr 15, 2022
Change to proper way to mount root SFC
SFC = single file component
yinxin630/blog#1
ChuanyuWang pushed a commit to ChuanyuWang/test that referenced this issue Jun 29, 2022
Change to proper way to mount root SFC
SFC = single file component
yinxin630/blog#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant