1π
β
To achieve this, You can use the toRaw
function to obtain the original non-reactive version of the formData
object and then use the reactive function to create a reactive copy of the formData
object and assign to submitData
variable.
Demo :
import { reactive, toRaw } from 'vue';
const formData = {...}
const submitData = reactive({ ...toRaw(formData) });
delete submitData.key;
π€Debug Diva
0π
You can create a shallow copy of formData
const submitData = { ...formData };
Or deep copy using cloneDeep
from lodash
const submitData = _.cloneDeep(formData);
Both will create a new object with the same properties and values as the original object. However, the new object is a separate entity in memory, distinct from the original object. Modifications made to the copy wonβt affect the original formData object.
π€Tony
Source:stackexchange.com