【发布时间】:2021-03-12 15:10:46
【问题描述】:
我目前正在过滤我的 JSON,如果我使用硬编码值过滤它就可以正常工作。
代码示例:
this.names= this.names.filter(function (name) {
return name.last== 'lastname';
});
它返回最后一个键的值为'lastname'的对象。但是,当我使用变量进行过滤时
代码:
this.names= this.names.filter(function (name) {
return name.last== this.selectedLname';
});
在控制台错误中显示无法读取 'selectedLname' 的属性,但 selectedLname 有一个值
【问题讨论】: