美文网首页
Vue-You are using the runtime-on

Vue-You are using the runtime-on

作者: inyourface | 来源:发表于2020-07-20 11:26 被阅读0次

一、出错原因

1.vue-cli脚手架的升级问题,报错:
You are using the runtime-only build of Vue where the template compiler is not available
2.原因
vue有两种形式的代码 分别是compiler(模板)模式和runtime模式(运行时),vue模块的package.json的main字段默认为runtime模式, 指向了"dist/vue.runtime.common.js"位置
在main.js文件中,初始化vue是compiler模式的,因此出现上面的报错信息。

  el: '#app',
  router: router,
  store: store,
  template: '<App/>',
  components: { App }
})

3.解决方法
3.1解法一:将mian.js中的代码修改:

  router,
  store,
  render: h => h(App)
}).$mount("#app")

3.2解法二:vue.config.js文件加上webpack的配置:

    resolve: {
      alias: {
        'vue$': 'vue/dist/vue.esm.js' 
      }
    }

相关文章

网友评论

      本文标题:Vue-You are using the runtime-on

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