mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
147 lines
4.5 KiB
Vue
147 lines
4.5 KiB
Vue
<template>
|
||
<div>
|
||
<p class="tip">键盘移动高亮行,设置 <table-api-link prop="keyboard-config"/>={isArrow: true} 启用方向键功能</p>
|
||
|
||
<vxe-table
|
||
border
|
||
resizable
|
||
show-overflow
|
||
highlight-current-row
|
||
ref="xTable"
|
||
height="300"
|
||
:loading="loading"
|
||
:keyboard-config="{isArrow: true}"
|
||
:scroll-y="{enabled: true}">
|
||
<vxe-column type="seq" width="100"></vxe-column>
|
||
<vxe-column field="name" title="Name" sortable width="200"></vxe-column>
|
||
<vxe-column field="age" title="Age" width="200"></vxe-column>
|
||
<vxe-column field="sex" title="Sex" width="200"></vxe-column>
|
||
<vxe-column field="rate" title="Rate" width="200"></vxe-column>
|
||
<vxe-column field="region" title="Region" width="200"></vxe-column>
|
||
<vxe-column field="time" title="Time" width="200"></vxe-column>
|
||
<vxe-column field="address" title="Address" width="300" show-overflow></vxe-column>
|
||
<vxe-column field="updateTime" title="UpdateTime" width="200"></vxe-column>
|
||
<vxe-column field="createTime" title="CreateTime" width="200"></vxe-column>
|
||
</vxe-table>
|
||
|
||
<pre>
|
||
<pre-code>
|
||
| Arrow Up ↑ | 移动到高亮行的上一行 |
|
||
| Arrow Down ↓ | 移动到高亮行的下一行 |
|
||
</pre-code>
|
||
</pre>
|
||
|
||
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
|
||
|
||
<pre>
|
||
<pre-code class="xml">{{ demoCodes[0] }}</pre-code>
|
||
<pre-code class="javascript">{{ demoCodes[1] }}</pre-code>
|
||
</pre>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data () {
|
||
return {
|
||
loading: false,
|
||
demoCodes: [
|
||
`
|
||
<vxe-table
|
||
border
|
||
resizable
|
||
show-overflow
|
||
highlight-current-row
|
||
ref="xTable"
|
||
height="300"
|
||
:loading="loading"
|
||
:keyboard-config="{isArrow: true}">
|
||
<vxe-column type="seq" width="100"></vxe-column>
|
||
<vxe-column field="name" title="Name" sortable width="200"></vxe-column>
|
||
<vxe-column field="age" title="Age" width="200"></vxe-column>
|
||
<vxe-column field="sex" title="Sex" width="200"></vxe-column>
|
||
<vxe-column field="rate" title="Rate" width="200"></vxe-column>
|
||
<vxe-column field="region" title="Region" width="200"></vxe-column>
|
||
<vxe-column field="time" title="Time" width="200"></vxe-column>
|
||
<vxe-column field="address" title="Address" width="300" show-overflow></vxe-column>
|
||
<vxe-column field="updateTime" title="UpdateTime" width="200"></vxe-column>
|
||
<vxe-column field="createTime" title="CreateTime" width="200"></vxe-column>
|
||
</vxe-table>
|
||
`,
|
||
`
|
||
export default {
|
||
data () {
|
||
return {
|
||
loading: false
|
||
}
|
||
},
|
||
created () {
|
||
this.loading = true
|
||
setTimeout(() => {
|
||
this.mockList(600).then(data => {
|
||
// 阻断 vue 对大数组的监听,大数据性能翻倍提升
|
||
if (this.$refs.xTable) {
|
||
this.$refs.xTable.loadData(data)
|
||
}
|
||
this.loading = false
|
||
})
|
||
}, 300)
|
||
},
|
||
methods: {
|
||
mockList (size) {
|
||
return new Promise(resolve => {
|
||
const list = []
|
||
for (let index = 0; index < size; index++) {
|
||
list.push({
|
||
name: \`名称\${index}\`,
|
||
sex: '0',
|
||
num: 123,
|
||
age: 18,
|
||
num2: 234,
|
||
rate: 3,
|
||
address: 'shenzhen'
|
||
})
|
||
}
|
||
resolve(list)
|
||
})
|
||
}
|
||
}
|
||
}
|
||
`
|
||
]
|
||
}
|
||
},
|
||
created () {
|
||
this.loading = true
|
||
setTimeout(() => {
|
||
this.mockList(600).then(data => {
|
||
// 阻断 vue 对大数组的监听,大数据性能翻倍提升
|
||
if (this.$refs.xTable) {
|
||
this.$refs.xTable.loadData(data)
|
||
}
|
||
this.loading = false
|
||
})
|
||
}, 300)
|
||
},
|
||
methods: {
|
||
mockList (size) {
|
||
return new Promise(resolve => {
|
||
const list = []
|
||
for (let index = 0; index < size; index++) {
|
||
list.push({
|
||
name: `名称${index}`,
|
||
sex: '0',
|
||
num: 123,
|
||
age: 18,
|
||
num2: 234,
|
||
rate: 3,
|
||
address: 'shenzhen'
|
||
})
|
||
}
|
||
resolve(list)
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|