炫意html5
最早CSS3和HTML5移动技术网站之一

vue用mock.js实现前后端分离的问题

module.exports = [
{
url: ‘/customerManagement/getList’,
type: ‘post’,
response(config) {
if (!config.body) {
return {
code: 200,
msg: ‘success’,
totalCount: count,
data: mock({
‘data|50’: [
{
uuid: ‘@uuid’,
id: ‘@id’,
schoolName: ‘@csentence(2, 4)’,
province: ‘@province’,
city: ‘@city’,
address: ‘@county()’,
contacts: ‘@cname’,
post: ‘@increment’,
telephone: ‘@natural()’,
numpro: ‘@increment’,
switch: ‘@boolean’,
percent: ‘@integer(80,99)’,
},
],
}).data,
}
}
const { schoolName = ”,
pageNo = 1,
pageSize = 20,
} = config.body
let mockList = List.filter((item) => {
return !(schoolName && item.schoolName.indexOf(schoolName) < 0)
// return !(city && item.city.indexOf(city) < 0)
// return !(province && item.province.indexOf(province) < 0)
})
const pageList = mockList.filter(
(item, index) =>
index < ppageSize * pageNo && index >= pageSize * (pageNo – 1)
)
return {
code: 200,
msg: ‘success’,
totalCount: count,
data: pageList,
}
},
},
]
这段内容是根据SchoolName查询的方法,我想再加个用省份(province)查询,该怎么写呀,copy一份会报错,前端小白鼠一枚,公司(小)也没有人会主管太忙没空教,请求各位大佬支援,拜托拜托,快秃了

回答

const { schoolName = '', province='',..} //解构一个传进来的省份参数

let mockList......


if(province){
mockList=mockList.filter(.....过滤)
}

pageList=mockList......

差不多就这样

炫意HTML5 » vue用mock.js实现前后端分离的问题

Java基础教程Android基础教程