vue3 遍历form表单时,如何让填写的内容一样?-灵析社区

云卿山手

vue3 遍历form表单时,如何让填写的内容一样? const formState = reactive({ studentId: undefined, coachId: undefined, contractId: undefined, startDate: '', startTime: '', endDate: '', endTime: '', memo: '', }); const formList = ref([formState]); 添加form const addForm = () => { formList.value.push(formState); }; ![](https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240916/e208cd2e76905baf2fafbc348c00a59b.png) ![](https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240916/d746e690cf240e914aa3ce9801844eb6.png) 求大佬们指导?

阅读量:172

点赞量:0

问AI
codbad
使用"JSON.parse(JSON.stringify())"进行深拷贝即可 const addForm = () => { formList.value.push(JSON.parse(JSON.stringify(formState))); };