1.记一个js 监听 watch里面清数据导致死循环的问题
>>You may have an infinite update loop in watcher with expression
//出现以上报错是因为监听ybjshid 时 清空了表单fydata的数据,其中fydata里面包含ybjshid这个属性,导致watch死循环
1. 处理方法:不要在监听属性的同时 ,清空属性
>>直接在js中修改 props里面的值,浏览器会报错
this.readonly=true;//就会报错
1. 处理方式: data(){return {
readonlyVal:this.readonly,
}}
//里面重新定义变量用来接收props里面的值,且在标签中引用的时候也引用自定义的readonlyVal
export default {
props : {
ryid : {
type : String,
default : ""
} ,
mode : {
type : String,
default : "FYJS"
} ,
fy : {
type : Object,
default : ( ) => {
return { } ;
}
} ,
readonly : {
type : Boolean,
default : false
}
} ,
computed : {
getQsZzrqZje : function ( ) {
const {
qsrq,
zzrq,
sjfsfyze
} = this . fydata;
return {
qsrq,
zzrq,
sjfsfyze
}
} ,
getYbJshid : function ( ) {
const {
ybjshid
} = this . fydata;
return {
ybjshid
}
}
} ,
watch : {
getYbJshid ( newdata ) {
console. log ( "==============new=" , newdata)
if ( newdata. ybjshid == '' || newdata. ybjshid== null ) {
this . jshsfbtBool= false ;
}
}
}
}