vue的slot-scope显示后端传来的数据

先上代码

<el-table>
  <el-table-column label="测试" >
     <template slot-scope="scope" prop="testType">
      //prop可以接收接口的参数,例如这个testType是后端传给你的用来选择状态的参数,就可以这样用
        <span v-if="scope.row.testType==0" >会议进行中</span>
        <span v-if="scope.row.testType==1" >会议准备中</span>
        <span v-if="scope.row.testType==2" >会议结束</span>
     </template>
  </el-table-column>
</el-table>

今天想显示后端的数据,但发现自己不会用slot-scope,后来查来资料发现是这这样用的
这是我的代码

<el-table-column prop="data" label="数据类型" width="180" >
         <template slot-scope="scope">
             <span v-if="scope.row.point==1" >实时数据</span>
             <span v-if="scope.row.point==2" >1小时数据</span>
             <span v-if="scope.row.point==3" >2小时数据</span>
             <span v-if="scope.row.point==4" >4小时数据</span>
             <span v-if="scope.row.point==5" >6小时数据</span>
             <span v-if="scope.row.point==6" >12小时数据</span>
             <span v-if="scope.row.point==7" >24小时数据</span>
            </template>
       </el-table-column>

结果是
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/he1234555/article/details/115250772