amis/mock/options/autoComplete2.js

44 lines
738 B
JavaScript
Raw Normal View History

2019-04-30 11:11:25 +08:00
const db = [
{
"label": "诸葛亮",
"value": "zhugeliang"
2019-04-30 11:11:25 +08:00
},
{
"label": "王昭君",
"value": "wangzhaojun"
2019-04-30 11:11:25 +08:00
},
{
"label": "钟馗",
"value": "zhongkui"
2019-04-30 11:11:25 +08:00
},
{
"label": "露娜",
"value": "luna"
2019-04-30 11:11:25 +08:00
},
{
"label": "钟无艳",
"value": "zhongwuyan"
2019-04-30 11:11:25 +08:00
},
{
"label": "花木兰",
"value": "huamulan"
2019-04-30 11:11:25 +08:00
}
];
module.exports = function(req, res) {
const term = req.query.term || '';
res.json({
status: 0,
msg: '',
data: term ? db.filter(function(item) {
return term ? ~item.label.indexOf(term) || ~item.value.indexOf(term) : false;
2019-04-30 11:11:25 +08:00
}) : db
});
}