為了引入.vue文件,安裝完vue-loader和vue-template-compiler后,運行報錯:
vue-loader was used without the corresponding plugin.Make sure to include VueLoaderPlugin in your webpack config.
是因為vue-loader,15的版本需要再添加plugin的配置。有兩種解決方法:
1.把安裝版本改為14的
2.在webpack.config.js中添加:
const { VueLoaderPlugin } = require('vue-loader') module.exports = { // ... plugins: [ new VueLoaderPlugin() ] }
如果直接去掉VueLoaderPlugin兩邊的{},會報錯,如下:TypeError: loaderContext.emitError is not a function at new module.exports ,想去掉這個{},需要把require里面的內容改一下
const VueLoaderPlugin = require('vue-loader/lib/plugin');
這樣就可以。