Vue测试监视程序更改,但内部代码未响应

问题描述 投票:0回答:1

在这种情况下,我无法从Vuex Store获得吸气剂,并且每当吸气剂发生变化(新值更新)时,都应重新分配本地状态数据(“列表”)。This is my component, which has 'list' in data

这是我的测试Successfully change the getSkills to the getSkillsMock, but there is no response from list, list is still an []

vue.js testing watch
1个回答
0
投票

观看数组或对象时,您需要将deep设置为true,以便Vue知道应该监视嵌套数据的更改。

watch: {
 getSkills: {
  handler () {
   this.list = this.getSkills.map(items => {
    return { value: items.id, label: items.name }
   })
  },
  deep: true
 }
}
© www.soinside.com 2019 - 2024. All rights reserved.