使用element UI-table表格列宽自适应 【已解决】
各种百度各种查,查了一些资料,发现有用width的有自己写的,一大堆看不懂
最后用 af-table-column 解决
在el-table中使用
1)安装
npm install af-table-column
2)在main.js中引用
import Vue from 'vue'
import ElementUI from 'element-ui'
//需要按需引入,先引入vue并引入element-ui
import AFTableColumn from 'af-table-column'
Vue.use(AFTableColumn)
3)在el-table中使用
<template>
<el-table :data="data">
<af-table-column label="列1" prop="field1"></af-table-column>
<af-table-column label="列2" prop="field2"></af-table-column>
<!--也支持简单的自定义内容-->
<af-table-column label="列3">
<template slot-scope="scope">
<div>自定义显示值31: {{ scope.row.field31 }}</div>
<div>自定义显示值32: {{ scope.row.field32 }}</div>
</template>
</af-table-column>
//也支持element-ui原有的el-table-column
<el-table-column label="操作">
<template slot-scope="scope">
<el-button @click="removeItem">删除</el-button>
</template>
</el-table-column >
//af-table-column 和el-table-column 可以同时在一个表格中使用
</el-table>
</template>
看前端面试题 大全 MST题库 小程序
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?