【发布时间】:2016-11-08 12:35:43
【问题描述】:
如果我这样设置状态对象:
const state: {
tools: {
tool1: {
status: true.
state:
},
tool2: {
status: false.
state: 1
}
}
}
在视图方面,当我使用突变更改例如状态时,一切都在正确更改。
但如果我使用 API 响应设置工具:
state.tools = response.tools;
如果响应 100% 相同,则不会发生任何事情。状态对象的变化也可以在 Vue 调试器中看到。
所以我尝试的是添加 常量状态:{ 工具: { 工具0:{ 状态:真实。 状态: } } }
并从 ajax 添加了 tool1 和 tool1(所以我的对象有 3 个子元素 tool0、tool1、tool3)。因此,如果我在 tool1 或 tool2(由 ajax 加载)上触发更改,则什么也没有发生。但是当我在 tool0 上触发更改(之前硬编码)时,一切正常 - 在这种情况下,还应用了在 ajax 加载的内容上设置的设置。
感谢任何提示!
【问题讨论】: