[email protected] VueLoaderPlugin無法loader

在安裝了Vue插件之後,發覺編譯不了.vue文件,但是已經把vue-loader vue-template-compiler 都下載完畢,並且還在webpack.config.js裏面配置了

 {test:/\.vue$/,use:'vue-loader'}

但是還是不行,一直提示:

client:162 ./src/login.vue
Module Error (from ./node_modules/[email protected]@vue-loader/lib/index.js):
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

後來發現是沒有配置 引包

const { VueLoaderPlugin } = require('vue-loader');

plugins:[
     new VueLoaderPlugin()
	]

配置完畢之後就可以正常的包vue文件了

 

附加:

 webpack中如何使用vue
//1.安裝vue包 cnpm i vue -D
//2.由於需要在webpack中要使用 .vue 這個組件模板定義組件 所以需要下載 安裝能夠解析 .vue 的loader
 //cnpm i vue-loader vue-template-compiler -D
 //3.在main.js文件中 導入vue模塊 import Vue from 'vue'
 //4.定義一個.vue結尾的組件,裏面的內容包括 template script style 這三大主標籤
 //5.需要在webpack.config.js 的配置文件裏面定義組件 {test:/\.vue/,use:'vue-loader'}
 //6.使用import xxx from './xxx.vue',導入這個組件
 //7創建vm實例 var vm = New Vue({el:'#app',render:c=>c(xxx)})
 //8.在頁面中創建一個id爲app的div元素,作爲vm實例控制的區域

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章