amis/mock/options/autoComplete.js
2019-04-30 11:11:25 +08:00

44 lines
676 B
JavaScript

const db = [
{
"label": "liaoxuezhi",
"value": "1"
},
{
"label": "zhangjun08",
"value": "2"
},
{
"label": "zhangtao07",
"value": "3"
},
{
"label": "wuduoyi",
"value": "4"
},
{
"label": "liuyiming04",
"value": "5"
},
{
"label": "zhangzhuobin",
"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
});
}