[Vue warn]: Property or method "name" is not defined on the instance but referenced during render

  小咸儿在做Vue项目的时候,有时候会在浏览器中看到Vue的警告,如下:
[Vue warn]: Property or method "name" is not defined on the instance but referenced during render

含义:页面使用了name,但是未定义

  在此有两种解决办法:

一:在定义变量区定义该属性

  在此可以查看你的data或者methods或者prop中有没有定义该属性

export default {
	data() {
		return {
			xxx::""
		}
	},
	methods: {
		xxx() {}
	}
}

二:在是在使用了表单验证的时候,解决办法

  在使用表单时,不可避免的会使用prop属性,可以看一下官网上对于prop属性的介绍:
[Vue warn]: Property or method "name" is not defined on the instance but referenced during render
  可以看出prop属性的类型是字符串,如果加上:,则**:prop**的值为data定义的一个属性值,如果去掉:,那么prop=“name”就是一个字符类型的,或者是使用:prop="‘name’",在中间的字段名上添加单引号。

特别感谢:小咸儿在解决问题的时候,主要参考了下面两篇博客,在此感谢两位博主。

方法一:在变量区定义

方法二:用于表单验证时