vue+elementui中的el-table中拼接接口返回的两个字段的数据并展示

1.

#1.遇到个问题就是其中有个 <el-table-column></el-table-column>要展示的数据来自接口返回的两个字段

2.

	<el-table :data="tableData(表格数据来源)" stripe style="width: 100%">
	<el-table-column prop="date(表格数据来源的某个字段)" label="日期(表格头部)" width="180">
	</el-table-column>
	原以为prop=" "中只能放一个字段的数据,想放两个字段数据的话,要把 <el-table-column></<el-table-column>标签再用

3.

<el-table :data="projNameOrCodeMenuList" class="parentNode"  @row-click="chooseParentNode">
  <el-table-column  class="parentNodeColumn" prop="projectName,projectCode" label="项目名称(代码)"  width="300">
    <template slot-scope="scope"> {
   
   {scope.row.projectName}}({
   
   {scope.row.projectCode}}) </template>
  </el-table-column>
</el-table>

4.

  记得原来<el-table-column></el-table-column>标签中的prop=" "中放两个
  <template slot-scope="scope"></template>中的slot-scope="scope" 最后通过{
   
   {scope.row.字段名}}

在这里插入图片描述

5.el-table 分页情况下index一直累加 ------亲测有效

	<el-table-column label="序号" type="index" :index="indexMethod"></el-table-column>

	methods:{
	    indexMethod(index){
	        index = (index + 1) + (页数 - 1) * 每页条数
	        return index
	    }
	}

猜你喜欢

转载自blog.csdn.net/weixin_53587375/article/details/119959339