我不知道如何在带有索引的 Ember.JS 中使用 Ember.set 功能。现在我一直在使用以下代码来实现此功能:
this.get('array')[index1][index2].value = value.target.value;
但是这一直给出以下错误:
ember.debug.js:16664 Uncaught Error: Assertion Failed: You must use Ember.set() to set the `value` property (of [object Object]) to `xxx`.
我想解决方案应该是这样的:
this.set('array'[index1][index2], value.target.value);
但是,我已经尝试了很多不同形式的上述解决方案,但似乎都不起作用。
数组的示例如下所示:
匹配数组:[
[{
“属性”:“路径名”,
“变量”:空,
“等于”:真实,
“运营商”:“等于”,
“值(value)”:空
}]
]
我正在使用 Ember v1.13 和 Node v4.4.3
最佳答案
试试下面的,
var k = this.get('matchingArray');
Ember.set(k[index1][index2],'value','Success');
样本 twiddle
关于javascript - 在 Ember 中使用带有索引的 set 函数作为键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37407530/