Unsure if there exists a computed set method that would be suitable in this scenario, however, there are several alternative approaches to tackle the issue.
If you require a single getter for modifying the data, utilizing an event-driven approach for setting the data could be beneficial. The following method is preferred:
export default {
template: `
<form class="add-upload" @submit.prevent="">
<label for="test"> test </label>
{{options.test}}
<input id="test" type="checkbox" v-model="options.test" @input="setOptions({test: !options.test})"/>
</form>
`,
data() {
return {
optionsData: {
test: false
}
}
},
computed: {
options: {
get() {
return this.optionsData;
},
},
},
methods: {
setOptions(options) {
this.$set(this, "optionsData", { ...this.optionsData, ...options })
}
}
}
If there is no need for complex logic within the get/set functions, using the data option directly can suffice
export default {
template: `
<form class="add-upload" @submit.prevent="">
<label for="test"> test </label>
{{options.test}}
<input id="test" type="checkbox" v-model="options.test" />
</form>
`,
data() {
return {
options: {
test: false
}
}
}
}
Additionally, there is the possibility of implementing get/set functions for each property individually
export default {
template: `
<form class="add-upload" @submit.prevent="">
<label for="test"> test </label>
{{test}}
<input id="test" type="checkbox" v-model="test" />
</form>
`,
data() {
return {
optionsData: {
test: false
}
}
},
computed: {
test: {
get() {
return this.optionsData.test;
},
set(value) {
this.optionsData.test = value
}
},
},
}