vue+webpack修改vue编译版本
vue+webpack报错:
build.js:10995 [Vue warn]: 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默认指向runtime模式的dist/vue.runtime.common.js
解决方法一:webpack配置文件配置别名:
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
}
解决方法二:import Vue from 'vue/dist/vue.esm.js' 不要直接import Vue from ‘Vue’
解决方法三: 去掉vue组件的模版template,用render模版(compiler)
vue有两种形式的代码 compiler(模板)模式和runtime模式(运行时),vue模块的package.json的main字段默认为runtime模式