Vue3 reactive对象使用const为何无法修改?-灵析社区

kunkun小黑子

vue3 中 reactive定义的对象,用const 却不能修改对容,用let就可以,我觉得reactive不管用let还是const都应该可以修改,引用数据类型,不知道为啥const不能,求解答 let numberValidateForm = reactive({ name: "", }); numberValidateForm.name = numberValidateForm.name.replace(/\s+ /g, ""); //能修改,换成const就不能

阅读量:14

点赞量:0

问AI
可以修改, 不知道你所谓不能修改是什么意思: const numberValidateForm = reactive({ name: "sd fa sdf", }); numberValidateForm.name = numberValidateForm.name.replace(/\s+ /g, ""); console.log(numberValidateForm.name, 'eq'); "image.png" (https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241102/d36d13141c5b19213ceb976e48847fe1.png)