reset reactive state vue 3

Solutions on MaxInterview for reset reactive state vue 3 by the best coders in the world

showing results for - "reset reactive state vue 3"
Elyas
02 Nov 2018
1// this not working for me if i have nasted array of object in intialState not sure way  
2setup() {
3    const initialState = {
4      name: "",
5      lastName: "",
6      email: ""
7    };
8
9    const form = reactive({ ...initialState });
10
11    function resetForm() {
12      Object.assign(form, initialState);
13    }
14
15    function setForm() {
16      Object.assign(form, {
17        name: "John",
18        lastName: "Doe",
19        email: "john@doe.com"
20      });
21    }
22
23    return { form, setForm, resetForm };
24  }
25