【发布时间】:2019-05-05 18:07:16
【问题描述】:
将 Typescript 与 Fuse.js 一起使用时出现此错误消息
TS2345:参数类型 '{ keys: string; }' 不能分配给'FuseOptions'。属性“键”的类型不兼容。类型“字符串”不能分配给类型“(“标题”|“ISBN”|“作者”)[]|| { 名称:“标题”| “国际标准书号”| “作者”;重量:数量; }[]'。
代码如下:
let books = [{
'ISBN': 'A',
'title': "Old Man's War",
'author': 'John Scalzi'
},
{
'ISBN': 'B',
'title': 'The Lock Artist',
'author': 'Steve Hamilton'
}
]
let options = {
keys: 'title'
}
let fuse = new Fuse(books, options)
let filterResult = fuse.search('old')
错误是悬停在let fuse = new Fuse(books, options)中的选项上时
【问题讨论】:
标签: reactjs typescript fuse.js