我的 Tags.ts 文件中有這些數據,但我不確定如何使用該名稱進行過濾。我可以使用普通的字符串列表來完成此操作,但不確定如何對數組執行此操作。任何建議或幫助,如何做到這一點。export const tags2: Array<Tag> = [{name: "Lam", superTag: true},{name: "Eliz", superTag: false},{name: "Cathy", superTag: true},{name: "John", superTag: false},{name: "James", superTag: false},{name: "David", superTag: false}];下面的代碼適用于普通字符串列表,但不適用于數組import { tags2 } from "./tags.data"; this._filteredTags = this.tags.filter((v: string) => v.toLowerCase().includes(filterValue.toLowerCase().trim()) ); }}
1 回答

弒天下
TA貢獻1818條經驗 獲得超8個贊
你必須檢查toLowerCase()
對象的名稱
this._filteredTags = this.tags.filter((v: string) => v["name"].toLowerCase().includes(filterValue.toLowerCase().trim()) );
- 1 回答
- 0 關注
- 95 瀏覽
添加回答
舉報
0/150
提交
取消