getList() { this.loading = true // 结果赋值给this.dataList listDishByPage(this.queryParams).then((response) => { this.dataList = response.data.list this.loading = false this.total = response.data.total } ) }<el-table-column label="编号" align="center" prop="dishNo" /> <el-table-column label="名称" align="center" prop="dishName" /> <el-table-column label="价格" align="center" prop="price" /> <el-table-column label="图片" align="center" prop="fileUrl" /> <el-table-column label="口味" align="center" prop="flavor" /> <el-table-column label="原材料" align="center" prop="ingredients" /> <el-table-column label="烹饪方式" align="center" prop="cookingMethod" />其中后端返回的image为文件名,需要调用selectByFileName,传入image参数,返回fileUrl,要怎么写

时间: 2023-08-20 10:06:02 浏览: 56
你可以在 getList() 方法中,在获取到菜品列表数据后,对每个菜品的 image 字段调用 selectByFileName() 方法,将其替换为返回的 fileUrl,例如: ``` getList() { this.loading = true; listDishByPage(this.queryParams).then((response) => { this.dataList = response.data.list; this.loading = false; this.total = response.data.total; this.dataList.forEach((dish) => { selectByFileName(dish.image).then((url) => { dish.fileUrl = url; }); }); }); } ``` 这个方法首先将 loading 状态设为 true,然后调用菜品列表接口,获取菜品列表数据。当数据返回后,将 loading 状态设为 false,并将列表数据和总数分别赋值给 this.dataList 和 this.total。接着,对于每个菜品,都调用 selectByFileName() 方法,将其 image 字段替换为返回的 fileUrl。最后,将处理好的列表数据渲染到 el-table 中。
相关问题

getFamily(id) { this.loading = true; listFamily({ studentId: id, pageNum: 1, pageSize: 99 }).then(response => { this.tableData = response.rows; this.loading = false; }); }, /** 查询招生信息列表 */ getList() { this.loading = true; listInformation(this.queryParams).then(response => { this.informationList = response.rows; this.total = response.total; this.loading = false; }); }, 怎么把this.tableData中的realName的值给this.informationList下的guardian

可以使用循环遍历的方式,将 `this.tableData` 中的 `realName` 值赋给 `this.informationList` 下的 `guardian` 属性。具体实现代码如下: ``` for(let i = 0; i < this.tableData.length; i++) { this.informationList[i].guardian = this.tableData[i].realName; } ``` 其中,`for` 循环遍历 `this.tableData` 中的每个对象,然后将对应的 `realName` 值赋给 `this.informationList` 中相同位置的对象的 `guardian` 属性。

fetchData() { // this.list = [] this.listLoading = true this.good.pageSize = this.pageSize this.good.pageIndex = this.currentPage4 console.log(this.good.uintPirce) if (this.good.uintPirce === '' || this.good.uintPirce === null) { this.good.uintPirce = 0 } getList(this.good).then(response => { this.list = response.data.records this.total = response.data.total this.pageSize = response.data.size // this.total = response.data.pages this.currentPage4 = response.data.current this.listLoading = false }) },解释以上每一行代码

以下是对您提供的代码片段的逐行解释: 1. `this.listLoading = true`: 将 `listLoading` 属性设置为 `true`,用于显示加载状态。 2. `this.good.pageSize = this.pageSize`: 将 `good` 对象的 `pageSize` 属性设置为当前的 `pageSize` 值。 3. `this.good.pageIndex = this.currentPage4`: 将 `good` 对象的 `pageIndex` 属性设置为当前的 `currentPage4` 值。 4. `console.log(this.good.uintPirce)`: 打印出 `good` 对象的 `uintPirce` 属性的值,用于调试目的。 5. `if (this.good.uintPirce === '' || this.good.uintPirce === null) { ... }`: 如果 `good` 对象的 `uintPirce` 属性为空字符串或者为 `null`,则执行下面的逻辑。 6. `this.good.uintPirce = 0`: 将 `good` 对象的 `uintPirce` 属性设置为 0。 7. `getList(this.good).then(response => { ... })`: 调用一个名为 `getList` 的函数,并将 `good` 对象作为参数传递给它。这个函数可能是获取列表数据的后端接口。 8. `.then(response => { ... })`: 如果获取列表数据成功,则执行回调函数,并将返回的响应作为参数传递给它。 9. `this.list = response.data.records`: 将返回的响应中的 `records` 属性赋值给 `list` 数组,用于显示列表数据。 10. `this.total = response.data.total`: 将返回的响应中的 `total` 属性赋值给 `total` 变量,用于显示总记录数。 11. `this.pageSize = response.data.size`: 将返回的响应中的 `size` 属性赋值给 `pageSize` 变量,用于显示每页记录数。 12. `this.currentPage4 = response.data.current`: 将返回的响应中的 `current` 属性赋值给 `currentPage4` 变量,用于显示当前页码。 13. `this.listLoading = false`: 将 `listLoading` 属性设置为 `false`,用于隐藏加载状态。 希望以上解释能对您有所帮助。如果您还有其他问题,请随时提问!

相关推荐

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]; } }); },

最新推荐

recommend-type

基于Java的IndexBar Android字母索引栏设计源码

IndexBar Android字母索引栏设计源码:该项目基于Java开发,包含49个文件,主要使用Java语言。该设计源码是一个Android字母索引栏,适用于实现类似目录的快速导航功能,便于用户快速找到所需内容。
recommend-type

中国新能源汽车供应链前瞻报告解构新时代整零关系-30页.pdf.zip

中国新能源汽车供应链前瞻报告解构新时代整零关系-30页.pdf.zip
recommend-type

CAD LSP 画门合页 插件

CAD LSP 画门合页 插件 CAD LSP 画门合页 插件 \zkm 左开门 ykm 右开门 kk 开启捕捉 bb 关闭捕捉 \ROM 打印和保存门尺寸 qx 全部图层显示
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

【实战演练】时间序列预测用于个体家庭功率预测_ARIMA, xgboost, RNN

![【实战演练】时间序列预测用于个体家庭功率预测_ARIMA, xgboost, RNN](https://img-blog.csdnimg.cn/img_convert/5587b4ec6abfc40c76db14fbef6280db.jpeg) # 1. 时间序列预测简介** 时间序列预测是一种预测未来值的技术,其基于历史数据中的时间依赖关系。它广泛应用于各种领域,例如经济、金融、能源和医疗保健。时间序列预测模型旨在捕捉数据中的模式和趋势,并使用这些信息来预测未来的值。 # 2. 时间序列预测方法 时间序列预测方法是利用历史数据来预测未来趋势或值的统计技术。在时间序列预测中,有许多不