做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

VUE element-ui 寫個復用Table組件的示例代碼

來源:懂視網 責編:小采 時間:2020-11-27 22:25:29
文檔

VUE element-ui 寫個復用Table組件的示例代碼

VUE element-ui 寫個復用Table組件的示例代碼:餓了么的table組件功能很強大,對于項目中的各種表格基本夠用,但是……個人對于它以列為單位的操作不習慣 =。=所以改成了另一種方式(我不會告訴你其實本質沒變)。 項目中表格較多,所以復用性最重要 步驟一 先來個基本的表格展示 官例的tableDat
推薦度:
導讀VUE element-ui 寫個復用Table組件的示例代碼:餓了么的table組件功能很強大,對于項目中的各種表格基本夠用,但是……個人對于它以列為單位的操作不習慣 =。=所以改成了另一種方式(我不會告訴你其實本質沒變)。 項目中表格較多,所以復用性最重要 步驟一 先來個基本的表格展示 官例的tableDat

餓了么的table組件功能很強大,對于項目中的各種表格基本夠用,但是……個人對于它以列為單位的操作不習慣 =。=所以改成了另一種方式(我不會告訴你其實本質沒變)。

項目中表格較多,所以復用性最重要

步驟一

先來個基本的表格展示

官例的tableData

tableData: [{
 date: '2016-05-02',
 name: '王小虎',
 address: '上海市普陀區金沙江路 1518 弄'
}, {
 date: '2016-05-04',
 name: '王小虎',
 address: '上海市普陀區金沙江路 1517 弄'
}, {
 date: '2016-05-01',
 name: '王小虎',
 address: '上海市普陀區金沙江路 1519 弄'
}, {
 date: '2016-05-03',
 name: '王小虎',
 address: '上海市普陀區金沙江路 1516 弄'
}]

table.vue

<template>
 <el-table :data="tableData" border>
 <el-table-column prop="date" label="日期"></el-table-column>
 <el-table-column prop="name" label="姓名"></el-table-column>
 <el-table-column prop="address" label="地址"></el-table-column>
 </el-table>
</template>

步驟二

簡化一下表格:

//table.vue
<template>
 <el-table :data="tableData" border>
 <el-table-column v-for="(item,key) in tableKey" 
 :key="key"
 :prop="item.value"
 :label="item.name"></el-table-column>
 </el-table>
</template>
<script>
export default{
 name: 'table',
 data(){
 return{
 tableData:[...],
 tableKey: [{
 name: 'date',
 value: '日期'
 },{
 name: '姓名',
 value: 'name'
 },{
 name: '地址',
 value: 'address'
 }]
 }
 }
}
</script>

步驟三

復用table.vue就是————給它數據的同時告訴它我的字段名唄

新建一個父組件sl_table.vue

//sl_table.vue
<template>
 <sl-table :tableData="tableData" :tableKey="tableKey"></sl-table>
</template>
<script>
import Table from '@/components/table'
export default{
 name: 'sl-table',
 data(){
 return {
 tableData: [...]
 tableKey: [{
 name: 'date',
 value: '日期'
 },{
 name: '姓名',
 value: 'name'
 },{
 name: '地址',
 value: 'address'
 }]
 }
 },
 components: {
 'sl-table': Table
 }
}
</script>

table.vue就更簡單了

//table.vue
<template>
 <el-table :data="tableData" border>
 <el-table-column v-for="(item,key) in tableKey" 
 :key="key"
 :prop="item.value"
 :label="item.name"></el-table-column>
 </el-table>
</template>
<script>
export default{
 name: 'table',
 data(){
 return{
 
 }
 },
 props:['tableData','tableKey'],
}
</script>

步驟四

可以根據需求修改table的形式

列寬度

這個較為簡單,可以直接加個屬性

//sl_table.vue
...
 data(){
 return {
 tableData: [...]
 tableKey: [{
 name: 'date',
 value: '日期',
 width: 80
 },{
 name: '姓名',
 value: 'name',
 width: 80
 },{
 name: '地址',
 value: 'address'
 }]
 }
 },
...

table.vue

//table.vue
...
<el-table-column v-for="(item,key) in tableKey" 
:key="key"
:prop="item.value"
:label="item.name"
:width="item.width"></el-table-column>
...

自定義模板列

如果我們需要告訴組件哪個是自定義的列,所以添加一個屬性operate

table.vue

<el-table-column v-for="(item,key) in tableKey" 
v-if="!item.operate"
:key="key"
:prop="item.value"
:label="item.name"
:width="item.width"></el-table-column>

<!-- 自定義 -->
<el-table-column v-else>
 <template scope="scope">
 <slot :name="item.value" :$index="scope.$index" :row="scope.row"></slot>
 </template>
</el-table-column>
//sl_table.vue
<sl-table :tableData="tableData" :tableKey="tableKey">
 <template slot="date" scope="scope">
 <span>{{ scope.row.date | DateFilter }}</span>
 </template>
</sl-table>
...
 data(){
 return {
 tableData: [...]
 tableKey: [{
 name: 'date',
 value: '日期',
 operate: true
 },{
 name: '姓名',
 value: 'name',
 operate: false
 },{
 name: '地址',
 value: 'address',
 operate: false
 }]
 }
 },
 filters: {
 DateFilter(){...}
 }
...

表格展開行

類似寬度,只要sl_table.vue傳入一個isExpand的屬性。這里加個每次只能展開一行的效果:

//sl_table.vue

<sl-table :tableData="tableData" :tableKey="tableKey" :isExpand="true" :isExpandOnly="true">
 <template slot="expand" scope="scope">
 {{...expand something}}
 </template>
 ...
</sl-table>

table.vue

//table.vue
<el-table :data="tableData" border @expand="handleExpand" ref="raw_table">
 <el-table-column v-if="isExpand" type="expand">
 <template scope="scope">
 <slot name="expand" :$index="scope.$index" :row="scope.row"></slot>
 </template>
 </el-table-column>
</el-table>
...
props: ['tableData','tableKey','isExpand','isExpandOnly'],
methods: {
 handleExpand(row,is_expand){
 if(this.isExpand && this.isExpandOnly){
 this.$refs.raw_table.store.states.expandRows = expanded ? [row] : [] 
 }
 }
}

其他的(排序、多選)操作也是類似添加。。多不贅述。

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

VUE element-ui 寫個復用Table組件的示例代碼

VUE element-ui 寫個復用Table組件的示例代碼:餓了么的table組件功能很強大,對于項目中的各種表格基本夠用,但是……個人對于它以列為單位的操作不習慣 =。=所以改成了另一種方式(我不會告訴你其實本質沒變)。 項目中表格較多,所以復用性最重要 步驟一 先來個基本的表格展示 官例的tableDat
推薦度:
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 石家庄市| 化隆| 河北区| 霍邱县| 临猗县| 雷州市| 佳木斯市| 仁化县| 临夏市| 梨树县| 大渡口区| 会理县| 金平| 康保县| 武川县| 德惠市| 永泰县| 井冈山市| 邵阳县| 夹江县| 乌兰察布市| 景德镇市| 靖安县| 武邑县| 海阳市| 毕节市| 天峻县| 溧阳市| 抚顺市| 延吉市| 龙泉市| 大洼县| 沧州市| 印江| 会宁县| 平安县| 安塞县| 天等县| 黄石市| 万安县| 娱乐|