What is the best way to update the entire observed array and trigger a rerender in vue.js without having to iterate an push all the items?
I have read the documentation here: https://vuejs.org/v2/guide/list.html#Replacing-an-Array
But it doesn't make sense to me having to filter, concat or slice just to update the array? There must be something I missed?
As suggested I will repond to this myself to help anyone in the same predicament.
oldArr = newArr
should still work (thank you choasia. Even though it is somewhat unclear in the vue.js documentation. Replacing the entire array will not fall under the caveats mentioned there (thank you Roy J ).
One option might also be to to empty the array and then push the new one like:
yourArray.push(... yourNewArray)
Thank you reiner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With