我使用的是easyAutocomplete的类别选项,因为我的json中有两组数据(文章和书籍)。他们的键虽然不同。文章=>标题和书籍=>名称
getValue选项显然不适用于类别,因为这样做时会出错。
如何为每个类别将getValue设置为不同的键?
这是我的json
{
"articles": [
{"title": "AAAA", "content": "123412341234"},
{"title": "BBBB", "content": "456745674567"},
...
],
"books": [
{"name": "CCCC", "content": "blah blah"},
{"name": "DDDD", "content": "blah blah"},
...
]
}
还有我的js
var options = {
url: function(phrase) {
return "/core/search?q=" + phrase;
},
categories: [
{
listLocation: "articles",
getValue: "title"
},
{
listLocation: "books",
getValue: "name"
}
],
list: {
match: {
enabled: true
}
}
};