I don't understand, please help. I have a counter that works through a setup, and I also have a form that is in the same setup, how can I combine them?
My code:
setup(props) {
const form = useForm({
name: props.user.name,
})
function update_shopItem() {
form.put(route('user.update', props.user.id))
}
return { form, update_shopItem }
const count = ref(1)
return {
count
};
},
I know that this is because there are two returns and only the first one is executed and after the code is interrupted, but how can I make it work otherwise that all the code inside the setup was executed? Tell me please. I want to make the counter work regardless of the const form.
CodePudding user response:
You could just use one return that takes the different properties :
setup(props) {
const form = useForm({
name: props.user.name,
})
function update_shopItem() {
form.put(route('user.update', props.user.id))
}
const count = ref(1)
return { form, update_shopItem, count}
},