美文网首页
vue踩坑记录

vue踩坑记录

作者: LemonTree7 | 来源:发表于2019-05-23 10:42 被阅读0次

1、 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有两种形式的代码 compiler(模板)模式和runtime模式(运行时),vue模块的package.json的main字段默认为runtime模式, 指向了"dist/vue.runtime.common.js"位置
这是vue升级到2.0之后就有的特点。
而我的app.vue文件中,初始化vue却是这么写的,这种形式为compiler模式的,所以就会出现上面的错误信息

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

解决方案:
将app.vue中的代码修改如下就可以

//runtime
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app")

参照:https://blog.csdn.net/wxl1555/article/details/83187647

相关文章

网友评论

      本文标题:vue踩坑记录

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