functionset(target, key, val){// 校验target , 不能为null、undefined、string、number、symbolif(process.env.NODE_ENV!=='production'&&(isUndef(target)||isPrimitive(target))){warn(`Cannot set reactive property on undefined, null, or primitive value: ${(target: any)}`)}// if(Array.isArray(target)&&isValidArrayIndex(key)){
target.length = Math.max(target.length, key)
target.splice(key,1, val)return val
}// 新增的property已经存在了,直接返回if(key in target &&!(key inObject.prototype)){
target[key]= val
return val
}const ob = target.__ob__
// target不能为vue实例 if(target._isVue ||(ob && ob.vmCount)){
process.env.NODE_ENV!=='production'&&warn('Avoid adding reactive properties to a Vue instance or its root $data '+'at runtime - declare it upfront in the data option.')return val
}// 检测target上的ob,如果没有就表明target没有设置过响应式,就简单为该target添加属性并返回if(!ob){
target[key]= val
return val
}// 为新增的属性添加响应式defineReactive(ob.value, key, val)// 通知观察过该属性的视图更新
ob.dep.notify()return val
}