网上好多都是一样的 还不行、、、、、、、、、、、
vue3获取vuex中的对象时为proxy对象,如何获取值
vue3获取vuex中的对象时为proxy对象,如何获取值
vue3获取vuex中的对象时为proxy对象,如何获取值
这个问题不是proxy问题,而是异步任务逻辑上不一样;
如
const fileChange = (obj: any) => {
console.log(obj);
console.log('image:', obj.fileList);
console.log('image_arr:', obj.fileList);
console.log('image_length:', obj.fileList.length);
setTimeout(() => {
console.log('增加setTimeout');
console.log('image_arr:', obj.fileList);
console.log('image_length:', obj.fileList.length);
}, 500);
};
结果分析
image: Proxy {}
CollectPhoto.vue?import&t=1657012147909:73 image_arr: Proxy {}
CollectPhoto.vue?import&t=1657012147909:74 image_length: 0
CollectPhoto.vue?import&t=1657012147909:77 增加setTimeout
CollectPhoto.vue?import&t=1657012147909:79 image_arr: Proxy {0: qo}
CollectPhoto.vue?import&t=1657012147909:80 image_length: 1
涉及原因:ref的处理,proxy原理,异步等