美文网首页
【前端】@vue/cli 4.1.2 页面空白

【前端】@vue/cli 4.1.2 页面空白

作者: 普鲁托蓝 | 来源:发表于2020-02-02 14:29 被阅读0次

@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模式,所以就会出现上面的错误信息。

解决办法

  1. 将main.js中的代码修改如下就可以
//runtime
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app")
  1. 在vue.config.js文件里加上webpack的如下配置即可
configureWebpack: {
    resolve: {
      alias: {
        'vue$': 'vue/dist/vue.esm.js' 
     }
 }

参考链接:https://blog.csdn.net/wxl1555/article/details/83187647

相关文章

网友评论

      本文标题:【前端】@vue/cli 4.1.2 页面空白

      本文链接:https://www.haomeiwen.com/subject/fwkqxhtx.html