assignment an new value to reactive object in onMounted lifecycle(script setup)
Version
3.2.20
Reproduction link
Steps to reproduce
1 using script setup;
2 in onMounted hook, modify array object width array.map method, then assignment to reactive object
What is expected?
myList is reactive
What is actually happening?
myList dosn't reactive
none
sorry to interrupt, may be i should do like this
const data =reactive( {
mylist: []
})
onMounted(() => {
data.myList = []
})
You should use a ref()
instead so you can replace the whole value.
Remember to use the forum or the Discord chat to ask questions!
You should use a
ref()
instead so you can replace the whole value.Remember to use the forum or the Discord chat to ask questions!
thank you very much! i wondering why use ref(.value) or reactive(reference) design, but i didn't find answer in rfcs issues, can you give me some tips?