const JSON = [
{
"name": "01,02"
},
{
"name": "01"
},
{
"name": "05"
},
{
"name": "06,09"
},
{
"name": "04,05"
},
{
"name": "02,03"
},
{
"name": "02,04,05"
},
{
"name": "01,02"
},
{
"name": "01,03"
}
]
function foo (str) {
const options = {
keys: ['name'],
threshold: 0,
location: 0,
distance: 100,
minMatchCharLength: str.length
}
const _fuse = new Fuse(JSON, options)
console.log(_fuse.search(str))
}
foo('03')
<script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.2.1/fuse.min.js"></script>
我正在尝试fuse.js
用于过滤。我不确定如何使用这些选项。如果我搜索,03
我不会返回任何结果。我试过改变位置和阈值,但没有完全理解。我将 设置为minMatchCharLength
查询字符串的长度,以防止查询01
返回仅包含0
. 那是对的吗?