el-dialog中el-table列宽调整 自动适应 以及 固定宽度

问题:设置了el-table每一列的宽度后,不会自动缩放了

方案:在标签<el-table-column prop="pin" label="" width="50%" > 中,

不要用 width 属性控制列宽

min-width 属性控制

width的现象如图:

min-width的现象如下图,el-table能够自适应屏幕缩放的同时,还能相对控制列宽

    <template>
      <div>
        <!-- Dialog Select Btn  -->
        <el-dialog  :visible.sync="dialogVisibleSelect"  title="Select Pin Params"   @close="handleDialogClose()">
          <template>
            <div>
              <el-table  :data="tableDataSelect" :cell-style="cellStyleSelect"
                         :header-cell-style="{fontSize: '12px', backgroundColor: '#f8f8f8',color:'#333'}"
              >
<!--                <el-table-column prop="pin" label="" width="50%" ></el-table-column>-->
<!--                <el-table-column prop="pin_value" label="" width="100%" ></el-table-column>-->
<!--                <el-table-column prop="E" label=""  width="50%"></el-table-column>-->
<!--                <el-table-column prop="E_value" label="" width="100%"></el-table-column>-->
<!--                <el-table-column prop="Fy" label="" width="50%" ></el-table-column>-->
<!--                <el-table-column prop="Fy_value" label=""  width="100%"></el-table-column>-->

                <el-table-column prop="pin" label="" min-width="50px" ></el-table-column>
                <el-table-column prop="pin_value" label="" ></el-table-column>
                <el-table-column prop="E" label="" min-width="50px" ></el-table-column>
                <el-table-column prop="E_value" label="" ></el-table-column>
                <el-table-column prop="Fy" label=""  min-width="50px" ></el-table-column>
                <el-table-column prop="Fy_value" label="" ></el-table-column>

                <el-table-column prop="editBtn" label=""   width="200%">
                  <template slot-scope="scope">
                    <el-button type="primary" @click="edit(scope.row)">edite</el-button>
                    <el-popconfirm title="sure to delete it?" @confirm="del(scope.row.id)">
                      <el-button slot="reference" type="danger" style="margin-left: 5px">delete</el-button>
                    </el-popconfirm>
                  </template>
                </el-table-column>
              </el-table>
            </div>

          </template>
        </el-dialog>
      </div>
    </template>

method--->控制单元格样式的

export default {

methods: {
    cellStyleSelect({row,column,rowIndex,columnIndex}){
      if ((columnIndex === 1 || columnIndex === 3 || columnIndex === 5)) {
        return {
          "background": "white",
          "color": "rgb(202, 1, 35)",

        };
      }
    }

}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值