amis/mock/options/autoComplete.js

44 lines
669 B
JavaScript
Raw Normal View History

2019-04-30 11:11:25 +08:00
const db = [
{
"label": "zhugeliang",
2019-04-30 11:11:25 +08:00
"value": "1"
},
{
"label": "zhongwuyan",
2019-04-30 11:11:25 +08:00
"value": "2"
},
{
"label": "buzhihuowu",
2019-04-30 11:11:25 +08:00
"value": "3"
},
{
"label": "zhongkui",
2019-04-30 11:11:25 +08:00
"value": "4"
},
{
"label": "luna",
2019-04-30 11:11:25 +08:00
"value": "5"
},
{
"label": "wangzhaojun",
2019-04-30 11:11:25 +08:00
"value": "6"
}
];
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) : false;
}) : db
});
}