0

So I have an Object that is empty and after the user submits the value, it is saved.

 let state = reactive({
      id: '',
      name: '',
      status: 0,
    } 

after the submit, I would like to save my values.

  onResult(() => {
        state.id = '1'
        state.name = 'Name'
        state.status = 1
      })

I would like to swap the complete object like I would do it in a ref, like:

state.value = {
  id: '1,
  name: 'Name',
  state: 1
};

Is there any shorthand when using reactive?

Non404
  • 1,130
  • 2
  • 12
  • 22

1 Answers1

1

This is not specific to reactive objects and would require to clear an object, which is inefficient.

This is the case for a ref. It can be unwrapped in a script if needed to skip value access:

const stateRef = ref({...})
const stateObj = shallowReadonly(stateRef);
Estus Flask
  • 206,104
  • 70
  • 425
  • 565