我尝试在组件中使用反应式数组。
它适用于一个对象,但不适用于一组对象。
数组更新时如何更新视图?
var self = currentClassInstance // this
self.store = {
resources: Vue.reactive([]),
test: Vue.reactive({ test: 'my super test' }),
setResources(resources) {
// this one doesn't update the view. ?
this.resources = resources
},
setResources(resources) {
// this one update the view
this.test.test = "test ok"
},
}
....
const app_draw = {
data() {
return {
resources: self.store.resources,
test: self.store.test,
}
},
updated() {
// triggered for "test" but not for "resources"
console.log('updated')
},
template: '<div v-for="(resource, key) …Run Code Online (Sandbox Code Playgroud)