element 的一些操作

关于表格

1、通过slot-scope="scope"添加操作按钮

<el-table-column>
<template slot-scope="scope">
 <el-button size="mini" type="primary">编辑</el-button>
 <el-button size="mini" type="danger">删除</el-button>
</template>
</el-table-column>

2、通过scope.$index获取当前行下标

<el-table-column label="操作" width="160">
   <template slot-scope="scope">
    <el-button size="mini" type="primary" plain @click = "showIndex(scope.$index)">点击显示当前行下标</el-button>
   </template>
 </el-table-column>

3、scope.row获取当前行的属性值

<el-table-column label="操作" width="160">
   <template slot-scope="scope">
    <el-button size="mini" type="primary" plain @click = "showName(scope.row.name)">点击获取姓名属性</el-button>
   </template>
</el-table-column>

4、设置表头样式 header-cell-class-name

//表头的设置
<el-table 
   :data="tableData[lang]"
   class="table"
   stripe 
   border 
   :header-cell-class-name="headerStyle"
  >
//js中编写headerStyle,返回class名称tablestyle
headerStyle ({row, column, rowIndex, columnIndex}) {
  return 'tableStyle'
  }
//style中编写样式
<style lang = "scss">
 .tableStyle{
 background-color: #1989fa!important;
 color:#fff;
 font-weight:400;
 }
</style>

//也可直接以对象的形式编写
<style lang = "scss">
 .tableStyle{
 background-color: #1989fa!important;
 color:#fff;
 font-weight:400;
 }
</style>

等待更新。。。

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

推荐阅读更多精彩内容

  • 最近的项目中使用到element-ui组件库,由于做的是后台管理系统,所以经常需要操作表格,编辑样式的过程中遇到一...
    视觉派Pie阅读 118,453评论 27 168
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 13,150评论 0 13
  • (o゜▽゜)o☆ 青椒味的Hello World 没有项目工程,没有vue脚手架,就一个HTML页面;没有干货,纯...
    dobby_l阅读 14,544评论 0 6
  • 1.badgeVaule气泡提示 2.git终端命令方法> pwd查看全部 >cd>ls >之后桌面找到文件夹内容...
    i得深刻方得S阅读 10,220评论 1 9
  • 漆黑的夜不见一点星光 我却用力的睁着双眼 搜寻着一点一点消失的思念 那个烟雨纷飞的季节 捏着远去的单程车票 泪不知...
    燕飞花阅读 2,669评论 11 14