cretueusebiu / vform

Handle Laravel-Vue forms and validation with ease.

Home Page:https://vform.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vue3 Reactivity

vincenzoraco opened this issue · comments

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,
      } ) )
    }
}

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,
      } ) )
    }
}