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是输入值的关联值,而且是必须设置的属性
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章