0
点赞
收藏
分享

微信扫一扫

sc——当后端返回的是一个二维数组时前端进行数据处理

日月同辉9908 2022-04-21 阅读 50
vueelementui

ps:当然这完全可以交给后端实现,调整他返回的数据格式 ,就不用这么麻烦,直接用就行了

 1、当用于element的el-popover时

效果:鼠标悬浮显示完整数据,不悬浮时溢出隐藏

<el-table-column align="center" label="仓库名称">
				<template slot-scope="scope">
					<el-popover placement="top-start" trigger="hover">
						{{scope.row.warehouse}}
						<div slot="reference" class="hide">
							{{scope.row.warehouse}}
						</div>
					</el-popover>
				</template>
</el-table-column>
getList() {
				//查询列表
				this.listLoading = true;
				request({
					url: "接口地址",
					method: "POST",
					data: {},
				}).then(data => {
					this.listLoading = false;//加载loading
					this.list = data.info.content;
					for (var i = 0; i < this.list.length; i++) {
						const warehouse = "";//字符串拼接
						for(var ii=0;ii < this.list[i].warehouse.length;ii++){							
							warehouse += this.list[i].warehouse[ii].name
							warehouse += ii < this.list[i].warehouse.length-1?",":"";							
						}						
						this.list[i].warehouse = warehouse;
					}
				})
			},

2、返回数据示例

举报

相关推荐

0 条评论