适用于子组件单纯想修改父组件值的场景
1. this.$emit('change',value)
value是新值,传递给子组件
适用于子组件先展示父组件的值,并且想更改uploadInfo的场景,uploadInfo在父组件也会被响应到newUploadInfo的修改
props: {
uploadInfo: {
type: Object,
default: () => ({}),
},
},
watch: {
uploadInfo: {
handler(value) {
this.newUploadInfo =value;
},
immediate: true,
},
}
this.newUploadInfo.xxx=1
console.log(this.uploadInfo.xxx) 也是为1