踩vue的bug

 bundle.js:896 [Vue warn]: Failed to mount component: template or render function not defined. 
 

Vue2.0有两种Build的方式:the standalone build and the runtime-only build(独立构建和运行时构建),可以知道:独立构建包括编译和支持template选项。但也要依赖于浏览器的API,所以不能用于服务端渲染。运行时构建不包括模板编译,并且不支持template选项,只能使用render选项。

重点来了,默认情况下,NPM包导出的是runtime-only build.因此为了要使用独立构建,在webpack配置中需要添加下面的代码:

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

然后就好了。。。
原文地址:https://www.cnblogs.com/yk-ontheway/p/6510812.html