getList(page, fenlei, ref = '') { if(fenlei == '全部') this.swiperIndex = -1; for(let i=0;i<this.fenlei.length;i++) { if(fenlei == this.fenlei[i]) { this.swiperIndex = i; break; } } this.curFenlei = fenlei; if (this.curFenlei == '全部') { this.isPlain = false; } else { this.isPlain = true; }
时间: 2023-12-06 10:43:04 浏览: 31
这段代码看起来是一个Vue组件中的方法,其中的参数page表示页数,fenlei表示分类,ref表示参考信息。首先判断分类是否为“全部”,如果是则把swiperIndex设置为-1,否则遍历分类数组this.fenlei并找到对应的分类,把swiperIndex设置为对应的索引值。然后将当前分类赋值给curFenlei变量,并根据curFenlei是否为“全部”来决定是否设置isPlain变量为false或true。
相关问题
getList(page, fenlei, ref = '') { if(fenlei == '全部') //首先判断分类是否为“全部” this.swiperIndex = -1;//如果是则把swiperIndex设置为-1 for(let i=0;i<this.fenlei.length;i++) {//遍历分类数组this.fenlei,找到对应的分类 if(fenlei == this.fenlei[i]) { this.swiperIndex = i;//把swiperIndex设置为对应的索引值 break; } } this.curFenlei = fenlei;//将当前分类赋值给curFenlei(当前分类)变量 if (this.curFenlei == '全部') {//根据curFenlei是否为“全部”来决定是否设置isPlain变量为false或true this.isPlain = false; } else { this.isPlain = true; } let params = {page, limit: this.pageSize}; let searchWhere = {}; if (this.formSearch.jingdianmingcheng != '') searchWhere.jingdianmingcheng = '%' + this.formSearch.jingdianmingcheng + '%'; if (this.formSearch.jingdiandizhi != '') searchWhere.jingdiandizhi = '%' + this.formSearch.jingdiandizhi + '%'; if(this.formSearch.menpiaojiagestart!='' && this.formSearch.menpiaojiagestart!=undefined ){ searchWhere.menpiaojiagestart = this.formSearch.menpiaojiagestart } if(this.formSearch.menpiaojiageend!='' && this.formSearch.menpiaojiageend!=undefined){ searchWhere.menpiaojiageend = this.formSearch.menpiaojiageend } if (this.curFenlei != '全部') searchWhere.jingdianleixing = this.curFenlei; this.$http.get('lvyoujingdian/list', {params: Object.assign(params, searchWhere)}).then(res => { if (res.data.code == 0) { this.dataList = res.data.data.list; this.total = res.data.data.total; this.pageSize = res.data.data.pageSize; this.totalPage = res.data.data.totalPage; this.pageSizes = [this.pageSize, this.pageSize*2, this.pageSize*3, this.pageSize*5]; } }); },
这是一个 Vue.js 的方法,用于获取旅游景点的列表数据。它接受三个参数,分别是页码、分类和 ref(默认为空字符串)。首先它会判断分类是否为“全部”,如果是则把 swiperIndex(轮播图的索引)设置为-1,否则遍历分类数组找到对应的分类并将 swiperIndex 设置为对应的索引值。然后将当前分类赋值给 curFenlei 变量,并根据 curFenlei 是否为“全部”来决定是否设置 isPlain 变量为 false 或 true。接下来根据传入的参数组装成查询条件 searchWhere,然后通过 HTTP GET 请求获取数据,并将获取到的数据赋值给 dataList、total、pageSize 和 totalPage 等变量。最后根据 pageSize 计算出 pageSizes 数组,并返回获取到的数据。
getList(page, fenlei, ref = '') { let params = {page, limit: this.pageSize}; let searchWhere = {}; if (this.formSearch.jingdianmingcheng != '') searchWhere.jingdianmingcheng = '%' + this.formSearch.jingdianmingcheng + '%'; this.$http.get('quxiaogoupiao/list', {params: Object.assign(params, searchWhere)}).then(res => { if (res.data.code == 0) { this.dataList = res.data.data.list; this.total = res.data.data.total; this.pageSize = res.data.data.pageSize; this.totalPage = res.data.data.totalPage; this.pageSizes = [this.pageSize, this.pageSize*2, this.pageSize*3, this.pageSize*5]; } }); },
这是一个前端Vue.js的方法,用于从后端API获取数据并更新页面。参数`page`表示当前页码,`fenlei`表示分类,`ref`表示引用,但似乎没有被使用。方法中首先定义了一个`params`对象,用于存储请求参数,包括当前页码和每页数据条数。然后定义了一个`searchWhere`对象,用于存储搜索条件。如果搜索条件中包含景点名称,则将`searchWhere.jingdianmingcheng`设置为包含该名称的字符串。最后使用`this.$http.get`方法发送GET请求,请求地址为`'quxiaogoupiao/list'`,请求参数为`params`和`searchWhere`对象的合并结果。当请求成功后,如果返回的`code`为0,则更新页面数据和分页信息。其中`this.dataList`表示当前页的数据列表,`this.total`表示数据总条数,`this.pageSize`表示每页数据条数,`this.totalPage`表示总页数,`this.pageSizes`表示可选的每页数据条数选项。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)