@vue/cli 4.1.2
运行没有报错,但页面空白。浏览器控制台看到报错
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
查了一下,是因为vue升级到2.0之后按照原有方式初始化vue的形式为compiler模式,所以就会出现上面的错误信息。
解决办法
- 将main.js中的代码修改如下就可以
//runtime
new Vue({
router,
store,
render: h => h(App)
}).$mount("#app")
- 在vue.config.js文件里加上webpack的如下配置即可
configureWebpack: {
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
}
网友评论