vue踩坑记录

2019-05-23  本文已影响0人  LemonTree7

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

上一篇 下一篇

猜你喜欢

热点阅读