Answers for "reset reactive state vue 3"

0

reset reactive state vue 3

// this not working for me if i have nasted array of object in intialState not sure way  
setup() {
    const initialState = {
      name: "",
      lastName: "",
      email: ""
    };

    const form = reactive({ ...initialState });

    function resetForm() {
      Object.assign(form, initialState);
    }

    function setForm() {
      Object.assign(form, {
        name: "John",
        lastName: "Doe",
        email: "[email protected]"
      });
    }

    return { form, setForm, resetForm };
  }
Posted by: Guest on October-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language