File tree Expand file tree Collapse file tree 2 files changed +54
-12
lines changed
en/ve-table/instance-methods
zh/ve-table/instance-methods Expand file tree Collapse file tree 2 files changed +54
-12
lines changed Original file line number Diff line number Diff line change 66<template >
77 <div >
88 <div style =" margin-bottom :20px ;line-height :3.0 ;" >
9- <button class =" button-demo" @click =" scrollToRowKey(30)" >滚动到rowKey为30的行</button >
10- <button class =" button-demo" @click =" scrollToRowKey(50)" >滚动到rowKey为50的行</button >
11- <button class =" button-demo" @click =" scrollToRowKey(0)" >滚动到rowKey为0的行</button >
9+ <button class =" button-demo" @click =" scrollToRowKey(9999)" >
10+ Scroll to the row with rowkey 9999
11+ </button >
12+ <button class =" button-demo" @click =" scrollToRowKey(9989)" >
13+ Scroll to the row with rowkey 9989
14+ </button >
15+ <button class =" button-demo" @click =" scrollToRowKey(5000)" >
16+ Scroll to the row with rowkey 5000
17+ </button >
18+ <button class =" button-demo" @click =" scrollToRowKey(0)" >
19+ Scroll to the row with rowkey 0
20+ </button >
1221 </div >
1322 <ve-table
1423 ref =" tableRef"
1524 style =" width :1000px "
1625 :scroll-width =" 1600"
17- :max-height =" 350 "
26+ :max-height =" 400 "
1827 border-y
1928 :columns =" columns"
2029 :table-data =" tableData"
2130 rowKeyFieldName =" rowKey"
31+ :virtual-scroll-option =" virtualScrollOption"
2232 />
2333 </div >
2434</template >
2737 export default {
2838 data () {
2939 return {
40+ virtualScrollOption: {
41+ // 是否开启
42+ enable: true ,
43+ minRowHeight: 40 ,
44+ },
45+ tableData: [],
3046 columns: [
3147 {
3248 field: " col1" ,
104120 };
105121 },
106122 methods: {
123+ getRandom (min , max ) {
124+ return Math .floor (Math .random () * (max - min) + min);
125+ },
107126 initTableData () {
108- let data = [];
109- for (let i = 0 ; i < 80 ; i++ ) {
110- data .push ({
127+ for (let i = 0 ; i < 10000 ; i++ ) {
128+ this .tableData .push ({
111129 rowKey: i,
112130 col1: i,
113131 col2: i,
119137 col8: i,
120138 });
121139 }
122- this .tableData = data;
123140 },
124141 // scroll y
125142 scrollToRowKey (rowKey ) {
Original file line number Diff line number Diff line change 66<template >
77 <div >
88 <div style =" margin-bottom :20px ;line-height :3.0 ;" >
9- <button class =" button-demo" @click =" scrollToRowKey(30)" >滚动到rowKey为30的行</button >
10- <button class =" button-demo" @click =" scrollToRowKey(50)" >滚动到rowKey为50的行</button >
9+ <button class =" button-demo" @click =" scrollToRowKey(9999)" >
10+ 滚动到rowKey为9999的行
11+ </button >
12+ <button class =" button-demo" @click =" scrollToRowKey(9989)" >
13+ 滚动到rowKey为9989的行
14+ </button >
15+ <button class =" button-demo" @click =" scrollToRowKey(5000)" >滚动到rowKey为50的行</button >
1116 <button class =" button-demo" @click =" scrollToRowKey(0)" >滚动到rowKey为0的行</button >
1217 </div >
1318 <ve-table
1419 ref =" tableRef"
1520 style =" width :1000px "
1621 :scroll-width =" 1600"
17- :max-height =" 350 "
22+ :max-height =" 400 "
1823 border-y
1924 :columns =" columns"
2025 :table-data =" tableData"
2126 rowKeyFieldName =" rowKey"
27+ :virtual-scroll-option =" virtualScrollOption"
2228 />
2329 </div >
2430</template >
2733 export default {
2834 data () {
2935 return {
36+ virtualScrollOption: {
37+ // 是否开启
38+ enable: true ,
39+ minRowHeight: 40 ,
40+ },
3041 columns: [
3142 {
3243 field: " col1" ,
104115 };
105116 },
106117 methods: {
118+ getRandom (min , max ) {
119+ return Math .floor (Math .random () * (max - min) + min);
120+ },
107121 initTableData () {
108122 let data = [];
109- for (let i = 0 ; i < 80 ; i++ ) {
123+ for (let i = 0 ; i < 10000 ; i++ ) {
124+ let value = " " ;
125+ if (i % 2 === 0 ) {
126+ const rowCount = this .getRandom (2 , 3 );
127+
128+ for (let i = 0 ; i < rowCount; i++ ) {
129+ value += ` this is the long word.<br />` ;
130+ }
131+ } else {
132+ value = ` name${ i} ` ;
133+ }
134+
110135 data .push ({
111136 rowKey: i,
112137 col1: i,
You can’t perform that action at this time.
0 commit comments