0👍
This solution should work and maintain reactivity.
-
You should be able to replace the entire array without using
splice
orset
. -
I have used a closure to capture
this
because sometimes the fetch call interferes with thethis
reference, even inside a lambda expression.
countryChangeHandler() {
this.states = []
const that = this
fetch(`/scripts/statejson.php?country=${this.country}`)
.then(response => response.json())
.then(res => {
that.states = res.states.map(it=>it.urlid)
})
},
- [Vuejs]-How to enable Vuex in Firebase Functions when deploying Nuxt app
- [Vuejs]-How to get the API response into my listrendering in vue 3?
Source:stackexchange.com