cretueusebiu / vform

Handle Laravel-Vue forms and validation with ease.
https://vform.vercel.app
MIT License
607 stars 120 forks source link

Vue3 Reactivity #139

Closed vincenzoraco closed 2 years ago

vincenzoraco commented 2 years ago

It is not an issue therefore I will be closing this ticket straight away, but I just wanted to let others how to deal with Vue3 reactivity:

Just wrap the form class instance inside a ref so it will reactive. You will obviously need to call functions and properties using form.value.post() for example.

import { ref } from 'vue'

export default {
    setup() {
      const form = ref( new Form( {
    name: null,
      } ) )
    }
}
CoffeeKing68 commented 2 years ago

I had to use reactive to get it to work. It seems like ref() removed the functions on my form? Not sure, but it worked.

import { reactive } from 'vue'

export default {
    setup() {
      const form = reactive( new Form( {
    name: null,
      } ) )
    }
}