筛选对象中的键或值
简易筛选
var tableData = {7: "A, 8: "B", 9: "C",}
this.handle(A,true)
handle(num, off) {
// num 是要判断的参数
// off 想要获取键填false
let text = "";
let json = this.tableData
// console.log(json)
Object.keys(json).forEach((item, index) => {
if (off) {
if (item == num) {
text = json[item];
}
} else {
if (json[item] == num) {
text = item;
}
}
});
return text;
},