vue錯誤整理

1、全局組件的註冊

  【問題】:Failed to mount component: template or render function not defined.
  【錯誤原因】:

在註冊全局組件時,沒有在new Vue()之前註冊,導致上述錯誤。

  【正確做法】:

// 創建一個組件Button.vue
...Button組件
// 在main.js中引入Button.vue並註冊,實現如下:
import Vue from 'vue';
import Button from 'Button.vue';
Vue.component('Button', Button);// 這個必須出現在new Vue({})之前
new Vue({});
2、vue-loader配置

  【問題】:vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.
  【錯誤原因】:

webpack版本問題,如果安裝的webpack版本是4.0以上,則會出現這個問題,改成4.0以下該問題會被修復
3、v-model與value
input標籤中,v-model與value不能同時存在的原因:
	vue是遵循W3C標準的,type=text使用用戶輸入值,type=checkbox使用輸入關聯值,v-model綁定值的作用;
	type=text:value=輸入值,type=checkbox:value是輸入值的關聯值,而且是必須設置的屬性
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章