element-ui中table使用tips

1.在表格中某列返回的是0,1,可通过formmatter进行转换文字展示

template中:

<el-table-column

    prop="status"

    label="有效状态"

    :formatter="statusFormate"

></el-table-column>

methods中定义

    statusFormate(row, index) {

      if (row.status == "1") {

        return "生效中";

      } else if (row.status == "0") {

        return "已失效";

      } else {

        return "";

      }

    },

2.给table-column-item加上fixed属性可将某列固定在某个位置

<el-table-column

        fixed="right"

      >

</el-table-column>

3.在table中获取某一行数据进行操作

<el-table-column

        label="操作"

      >

    <template slot-scope="scope">

        <el-button

        @click="handleDetail(scope.$index, scope.row)"

        >详情</el-button>

    </template>

</el-table-column>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。