亚洲女同成aV人片在线观看|亚洲www啪成人一区二区麻豆|亚洲国产中日韩精品综合|亚洲国产成人精品一级片|亚洲无码在线视频免费

天津九安特機電工程有限公司

導航切換

聯(lián)系電話(huà):
19930496374

天津九安特機電工程有限公司

vue+element table的二次封裝

作者:天津九安特機電工程有限公司 來(lái)源: 天津九安特機電工程有限公司   日期:2026-05-04 16:51:28

table.vue??文件

<el-tabl??e<??(???); p=''>

<pre class="wp-block-code" style='box-si??zin??g: border-box; font-size: 13px; overflow: auto; font-family: Menlo,次封 Monaco, Consolasヽ(′ー`)ノ, 'Courier New', monospace; word-spacing: 0px; text-tr??ansform: none; word-break: break-all; font-weight: 300; color: #333333; font-style: no(╬?益?)rmal; orphans: 2; widows: 2; margin:?? 0px 0px 10px; display: bloc(′▽?zhuān)?k; letter-spacing: normal; line-height: 1.4285; background-color: #f5?f5f5; text-indent: 0px; font-variant-ligatu(′?_?`)res: normal; font-variant-caps: normal; -webkit-text-stroke-(′?_?`)width: 0px; text-decoration-style: in??itial; text-decoration-color: initial; overflow-wrap: break-word; border-radius: 0px; border: #ccccc??c?? 1px solid; padding: 9px;'><co(′;ω;`)de style="box-sizing: borde(′?`)r-box; font-family: Menlo, Monaco, Co(′▽?zhuān)?)nsolas, 'Courier New'(????), monosp??ace; white-space: pre-wr??ap; margin: 0px 5px; background-color: transparent; border-radius: 0px; bo(?_?;)rder: #e1e1e1 1px??(╯°□°)╯︵ ┻━┻ solid; padding: 0px;"><te(╬?益?)mplate> <el-(╯°□°)╯table :data='tableData' styl??e="width: 100%" :row-class-name='tabl(′▽?zhuān)?eRowClassName' :cell-style="{ textAlign:'center'}" @selection-change="change" :show-header='showHeader' :borde(°□°)r='border' :ma(╯‵□′)╯x-height='maxHeight' :v-load(′?_?`)i??ng??="loading" :class='className' element-loading-text="給我一點(diǎn)時(shí)間" str??ipe fit highlight-current-row > <temp??late v-f(/ω\)or="tableColumn in tabl??eList"> <el-table-column :type="tableColumn.type" :width='tableColumn.width' v-if??="tableColumn.type === 'selection'" ></el-table-column><!--(′▽?zhuān)? slot 添加自定義配置項--> <slot v-if="tableColumn.slot" :name='tabl(??ヮ?)?*:???eColumn.slot' ></slot> <!-- co(′?`)mponent 特殊處理某一項--( ???)> <component v-else-if="t??ableColuヾ(′▽?zhuān)??mn.component" :is='config.component' :col-config="tableColumn" ></comp??onent> <el??-table-column :label="tableColumn.label" :type="tableColumn.type" :prop="tableColumn.prop" :width="tableColumn.width" :fixed='tableColumn.fixed ' :sorta??ble='tableColumn.sortable' v-if='(tableColumn.type !== 'se(//ω//)lection')&&(tableColumn.type !== 'slot')' &g??t; </el-table-column> </template> </el-table></(???)template&??gt;<??;script> export default { data(){ return{ } }, props: { tab??leList: { type: Array, default: func??(????)tion() { return []; } }, tableData: { type: Array, default: function() { retu??rn []; } }, showHeader: { type:?? Boolean, default: true }, border: { type: Boolean, default: false }, maxHeight: { type: [String, Numbe??r], default: nulヽ(′▽?zhuān)?ノl }, loading: { type: Boolean, default: false }, className: { type: String, default: "" }, tableRowClassName: { type: String, default: "" } } }</script><styl(╯‵□′)╯e scoped></style></cod??e></pre&g(′?`)t(′▽?zhuān)?);

很多人不明白為什么這里要加一個(gè)slot,這個(gè)封裝實(shí)際上就是次(ci)封把前面的tableList 作為一個(gè) prop 傳入,通過(guò)這個(gè)屬性,次封我們就可以在table中編輯任何簡(jiǎn)單或者復制的次封列, 完美~

使用方法如下:

<pre class="wp-block-code"><code><template> <my-tヽ(′?`)ノable :tableData="tableData" :tableList="colConfigs"> </my-tab??le></template><script> const?? Prefix??PlusText = { props: ['colConfig'(′?`)],次封 template: ` <el-tab(′_`)le-column :label='colConfig.la(′?_?`)bel'> <span :slot-scope="{ row }"> { { parseInt((╯°□°)╯row[co(╯°□°)╯lConfig.prop]) > 0 ? '+' + row[colConfig.prop] : row[colConfig.prop] }} </span> </el-table-column> `} export default { data () { this.colConfigs = [ { prop: 'change', label: '變化' component: PrefixPlusText }, { prop: 'name', label: '趨勢', component: PrefixPlusText }, ] return { tableData: [{ change: '12%', trend: '10% }, { change: '-12%', trend: '-10%' }] } }}</script></code></pre>

總結

table 作為數據展示組件,在日常開(kāi)發(fā)中(zhong)經(jīng)常被用到??,次(ci)封通過(guò)這篇文章,次封可以看到結合 vue 的次封 slot/component 特性,做一層封裝,次封可以大大簡(jiǎn)化 tab??le 的次封使用,大部分時(shí)候只需寫(xiě)一個(gè)??(╬?益?)配置屬性就可以了。次封

次封

文章來(lái)源:田珊珊個(gè)人博客

次封

來(lái)源地址:http://www.tianshan277.com/708.html

次封
亚洲女同成aV人片在线观看|亚洲www啪成人一区二区麻豆|亚洲国产中日韩精品综合|亚洲国产成人精品一级片|亚洲无码在线视频免费 当涂县| 吉林省| 平南县| 大埔县| 盘山县| 保山市| 嫩江县| 龙陵县| 九台市| 恩平市| 柳林县| 罗山县| 梁河县| 昌黎县| 泰安市| 册亨县| 凤山市| 富锦市| 栾川县| 双牌县| 简阳市| 通渭县| 台湾省| 科技| 临潭县| 大荔县| 巧家县| 宁明县| 封丘县| 洪泽县| 永和县| 额敏县| 华坪县| 东明县| 保定市| 象州县| 乌拉特中旗| 肇东市| 武威市| 南康市| 西乡县| http://444 http://444 http://444 http://444 http://444 http://444