|
5 | 5 | <div> |
6 | 6 | <v-table |
7 | 7 | :width="1100" |
8 | | - :height="430" |
9 | | - :columns="tableConfig.columns" |
10 | | - :table-data="tableConfig.tableData" |
| 8 | + :height="300" |
| 9 | + :columns="columns" |
| 10 | + :table-data="tableData" |
11 | 11 | even-bg-color="#f4f4f4" |
12 | 12 | row-hover-color="#eee" |
13 | 13 | row-click-color="#edf7ff" |
|
18 | 18 |
|
19 | 19 | <script> |
20 | 20 | import Vue from 'vue' |
21 | | - import mockData from '../../mock/tableData.js' |
22 | 21 |
|
23 | 22 | export default{ |
24 | 23 | name: 'frozen-title-columns', |
25 | 24 | data(){ |
26 | 25 | return { |
27 | | - tableConfig: { |
28 | | - tableData: [], |
29 | | - columns:[ |
30 | | - {field: 'name', title:'姓名', width: 150, titleAlign: 'center',columnAlign:'center', isFrozen: true}, |
31 | | - {field: 'gender', title:'性别', width: 150, titleAlign: 'center',columnAlign:'center', isFrozen: true}, |
32 | | - {field: 'tel', title: '手机号码', width: 180, titleAlign: 'center',columnAlign:'center', isFrozen: false}, |
33 | | - {field: 'birthday', title: '出生日期', width: 180, titleAlign: 'center',columnAlign:'center'}, |
34 | | - {field: 'hobby', title: '爱好', width: 380, titleAlign: 'center',columnAlign:'center'}, |
35 | | - {field: 'address', title: '地址', width: 430, titleAlign: 'center',columnAlign:'left'} |
36 | | - ] |
37 | | - } |
| 26 | + tableData: [{"name":"赵伟","gender":"男","birthday":'1963-7-9',"height":"183","email":"[email protected]","tel":"156*****1987","hobby":"钢琴、书法、唱歌","address":"上海市黄浦区金陵东路569号17楼"}, |
| 27 | + {"name":"李伟","gender":"男","birthday":'2003-12-7',"height":"166","email":"[email protected]","tel":"182*****1538","hobby":"钢琴、书法、唱歌","address":"上海市奉贤区南桥镇立新路12号2楼"}, |
| 28 | + {"name":"孙伟","gender":"女","birthday":'1993-12-7',"height":"186","email":"[email protected]","tel":"161*****0097","hobby":"钢琴、书法、唱歌","address":"上海市崇明县城桥镇八一路739号"}, |
| 29 | + {"name":"周伟","gender":"女","birthday":'1993-12-7',"height":"188","email":"[email protected]","tel":"197*****1123","hobby":"钢琴、书法、唱歌","address":"上海市青浦区青浦镇章浜路24号"}, |
| 30 | + {"name":"吴伟","gender":"男","birthday":'1993-12-7',"height":"160","email":"[email protected]","tel":"183*****6678","hobby":"钢琴、书法、唱歌","address":"上海市松江区乐都西路867-871号"}, |
| 31 | + {"name":"冯伟","gender":"女","birthday":'1993-12-7',"height":"168","email":"[email protected]","tel":"133*****3793","hobby":"钢琴、书法、唱歌","address":"上海市金山区龙胜路143号一层"}, |
| 32 | + {"name":"褚伟","gender":"男","birthday":'1993-12-7',"height":"170","email":"[email protected]","tel":"189*****2345","hobby":"钢琴、书法、唱歌","address":"上海市闵行区都市路2988号2楼"},], |
| 33 | + columns:[ |
| 34 | + {field: 'name', title:'姓名', width: 150, titleAlign: 'center',columnAlign:'center', isFrozen: true}, |
| 35 | + {field: 'gender', title:'性别', width: 150, titleAlign: 'center',columnAlign:'center', isFrozen: true}, |
| 36 | + {field: 'tel', title: '手机号码', width: 180, titleAlign: 'center',columnAlign:'center', isFrozen: false}, |
| 37 | + {field: 'birthday', title: '出生日期', width: 180, titleAlign: 'center',columnAlign:'center'}, |
| 38 | + {field: 'hobby', title: '爱好', width: 380, titleAlign: 'center',columnAlign:'center'}, |
| 39 | + {field: 'address', title: '地址', width: 430, titleAlign: 'center',columnAlign:'left'} |
| 40 | + ] |
38 | 41 | } |
39 | 42 | }, |
40 | 43 | methods: { |
41 | | - // 模拟获取数据 |
42 | | - getTableData(){ |
43 | | - var self = this |
44 | 44 |
|
45 | | - setTimeout(function () { |
46 | | - self.tableConfig.tableData = mockData |
47 | | - }, 100) |
48 | | - }, |
49 | 45 | cellMerge(rowIndex,rowData,field){ |
50 | 46 | if (field === 'name' && rowData[field] === '李伟') { |
51 | 47 | return { |
|
74 | 70 | } |
75 | 71 | } |
76 | 72 | } |
77 | | - }, |
78 | | - created(){ |
79 | | - this.getTableData() |
80 | 73 | } |
81 | 74 | } |
82 | 75 |
|
|
0 commit comments