[Vue warn]:You are using the runtime-omly build of Vue where the template compiler is not available.Either pre-compile the templates into render functions,or use the compiler-included build.
你正在使用 runtime-only版本构建Vue版本,这里的template编译是无效的
这个报错是因为Vue在最终构建发布版本的时候,构建了两类版本:
- runtime-only =>代码中不可以有任何的template(该版本不包含对template编译的代码)
- runtime-compiler =>代码中可以有template(有compiler可以用于编译template)
此时,在webpack.config.js内配置一个resolve即可(与module同级)
resolve: {
//别名
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
}
此时,将vue指向vue.esm.js
默认情况下指向vue.runtime.js
然后重新打包运行即可。