Vue element-UI在表格中使用prop属性的方法

1,498 阅读1分钟

这里遇到一个需求实在表格中使用图片展示活动的头像 一开始使用el-table来做表格每一个分列都是使用prop属性来作为这个表格中的字段,但是在image当中你需要将字段作为image的src来使用因此使用了插件里面套用scope然后使用scope属性的办法来实现

//Vue Element-UI
<el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column sortable prop="id" label="序号" width="110">
      </el-table-column>
      <el-table-column sortable prop="image" label="图片" width="100">
        <template slot-scope="scope">
          <el-image :src="scope.row.image"></el-image>
        </template>
      </el-table-column>
      <el-table-column sortable prop="name" label="发起者昵称" width="200">
      </el-table-column>
      <el-table-column sortable prop="originator_id" label="发起者id" width="100">
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="300">
        <template slot-scope="scope">
          <el-button size="mini" type="warning" @click="jump(scope.row.id)">查看</el-button>
          <el-button size="mini"  type="success" @click="acceptActivity(scope.$index, scope.row.id)">同意</el-button>
          <el-button size="mini" type="danger" @click="refuseActivity(scope.$index, scope.row.id)">拒绝</el-button>
        </template>
      </el-table-column>
    </el-table>