Closed jingyuexing closed 1 year ago
I wonder what if we update the passed array while using useSelection
:
const items = ref(['apple', 'banana', 'orange', 'watermelon'])
const { options, select, value } = useSelection({
items: items,
multi: isMultiEnabled,
})
setTimeout(() => {
items.value.push('mango')
}, 2000);
Can you please give it a try and let know if above works?
I wonder what if we update the passed array while using
useSelection
:const items = ref(['apple', 'banana', 'orange', 'watermelon']) const { options, select, value } = useSelection({ items: items, multi: isMultiEnabled, }) setTimeout(() => { items.value.push('mango') }, 2000);
Can you please give it a try and let know if above works?
I'm not sure if you are showing me another way to achieve the same goal. As for the above code, there's no problem and it can run as expected.
When I used the Closable feature of the Chip component in an actual project, I found that there were many limitations, such as being unable to delete or add items freely. Therefore, I wrote an enhanced version of the useSelection hook. Since I only tested it in my own project, I cannot predict how it will work in your project. Please modify it according to your specific situation.
Two new hooks have been added: close, which removes an element from the items array, and append, which adds an element to the items array.