1👍
✅
You could wrap that reactive properties by reactive
function named state
:
const state = reactive({
page: '1',
item: '1',
product: 'ok',
note: 1,
})
const update = (object) => {
const properties: Array<keyof typeof state> = ['page', 'item', 'product', 'note']
properties.forEach((prop) => {
if (prop in object) {
state[prop] = object[prop]
}
})
}
const object: Partial<state> = {
note: 'new value for note',
}
update(object)
Source:stackexchange.com