#author("2022-08-12T09:46:13+08:00","default:Admin","Admin")
#author("2022-09-02T14:41:36+08:00","default:Admin","Admin")
[[Vue]]

&color(red){※前提条件:本文基于 Vue 2.0 创作};
#contents

* [Vue warn]: Property or method "changeSetting" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. [#ee36f8fd]

代码:
#codeprettify{{
<CustomForm ref="form"
  :changeSetting="changeSetting"
  :disForm="!canEdit"
  :sup_this="this"
  :is-add="isAdd"></CustomForm>
}}

- 可能性1:上面的虽有使用,但是其他地方没有定义,此时只需删掉变量即可
- 可能性2:涉及到使用prop父子组件传值时,有可能是子组件的,props里面没有定义changeSetting造成的
- 可能性3:变量被控件绑定使用了,但是在 data 里面没有定义,此时只需在 data 里面添加定义即可
* [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "formData" [#a9fe42d6]

原因:组件内直接修改props的值会报错
#codeprettify{{
props: {
    formData: {
      type: Object,
      default: null,
    },
}}

解决方法: 
+ 在子组件使用该值时需要经过新变量(chooseType)重新传递,这样当这个值变更时,不会造formData的更改
+ 在vue2中,直接修改prop是被视作反模式的。由于在新的渲染机制中,每当父组件重新渲染时,子组件都会被覆盖,所以应该把props看做是不可变对象。不能更改 quantity prop使其和父组件同步 , 而是让应该这个组件提交个事件给父组件,可以 watch formData 变量,如果变量发生改变就使用 [[$emit 事件>+Vue+props#r462bf6a]] ,所以这里压根不需要 prop,直接将props里面的formData删掉即可。

* Invalid default value for prop “XX”: Props with type Object/Array must use a factory function to return the default value. [#m3594f0b]

#codeprettify{{
//错误写法
props: {
	rlist: {
		type:Array,
		default: [1, 2, 3, 4, 5]
	}
}
}}

#codeprettify{{
//正确写法
props: {
	rlist: {
		type:Array,
		default: function() {
			return [1, 2, 3, 4, 5]
		}
	}
}
}}

* Error in created hook: "TypeError: Cannot read properties of undefined (reading 'tableId')" [#v63511cf]

原因:

在 el-form 里面使用了 el-table-column 的要素,导致无法找到 table 的Id



* TypeError: Cannot read properties of undefined (reading ‘split‘) [#uf3e0189]

split报错??!!

split 切割对象的字符串,如果为空就有可能报此错误

* Cannot read properties of undefined (reading '0') [#p65fcf3b]

对数组的数据取值时,数组的变量没值时,发生这个问题

* regeneratorRuntime is not defined [#kd09ef2b]

async/await的使用不当

#hr();
コメント:
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS