mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
112 lines
3.9 KiB
Vue
112 lines
3.9 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}">
|
||
<vxe-table-column type="seq" width="100"></vxe-table-column>
|
||
<vxe-table-column field="name" title="Name" sortable width="200"></vxe-table-column>
|
||
<vxe-table-column field="age" title="Age" width="200"></vxe-table-column>
|
||
<vxe-table-column field="sex" title="Sex" width="200"></vxe-table-column>
|
||
<vxe-table-column field="rate" title="Rate" width="200"></vxe-table-column>
|
||
<vxe-table-column field="region" title="Region" width="200"></vxe-table-column>
|
||
<vxe-table-column field="time" title="Time" width="200"></vxe-table-column>
|
||
<vxe-table-column field="address" title="Address" width="300" show-overflow></vxe-table-column>
|
||
<vxe-table-column field="updateTime" title="UpdateTime" width="200"></vxe-table-column>
|
||
<vxe-table-column field="createTime" title="CreateTime" width="200"></vxe-table-column>
|
||
</vxe-table>
|
||
|
||
<pre>
|
||
<code>
|
||
| Arrow Up ↑ | 移动到高亮行的上一行 |
|
||
| Arrow Down ↓ | 移动到高亮行的下一行 |
|
||
</code>
|
||
</pre>
|
||
|
||
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
|
||
|
||
<pre>
|
||
<code class="xml">{{ demoCodes[0] }}</code>
|
||
<code class="javascript">{{ demoCodes[1] }}</code>
|
||
</pre>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import hljs from 'highlight.js'
|
||
|
||
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-table-column type="seq" width="100"></vxe-table-column>
|
||
<vxe-table-column field="name" title="Name" sortable width="200"></vxe-table-column>
|
||
<vxe-table-column field="age" title="Age" width="200"></vxe-table-column>
|
||
<vxe-table-column field="sex" title="Sex" width="200"></vxe-table-column>
|
||
<vxe-table-column field="rate" title="Rate" width="200"></vxe-table-column>
|
||
<vxe-table-column field="region" title="Region" width="200"></vxe-table-column>
|
||
<vxe-table-column field="time" title="Time" width="200"></vxe-table-column>
|
||
<vxe-table-column field="address" title="Address" width="300" show-overflow></vxe-table-column>
|
||
<vxe-table-column field="updateTime" title="UpdateTime" width="200"></vxe-table-column>
|
||
<vxe-table-column field="createTime" title="CreateTime" width="200"></vxe-table-column>
|
||
</vxe-table>
|
||
`,
|
||
`
|
||
export default {
|
||
data () {
|
||
return {
|
||
loading: false
|
||
}
|
||
},
|
||
created () {
|
||
this.loading = true
|
||
setTimeout(() => {
|
||
let tableData = window.MOCK_DATA_LIST.slice(0, 600)
|
||
// 使用函数式加载,阻断 vue 对大数组的监听,大数据性能翻倍提升
|
||
if (this.$refs.xTable) {
|
||
this.$refs.xTable.loadData(tableData)
|
||
}
|
||
this.loading = false
|
||
}, 300)
|
||
}
|
||
}
|
||
`
|
||
]
|
||
}
|
||
},
|
||
created () {
|
||
this.loading = true
|
||
setTimeout(() => {
|
||
// 阻断 vue 对大数组的监听,大数据性能翻倍提升
|
||
if (this.$refs.xTable) {
|
||
this.$refs.xTable.loadData(window.MOCK_DATA_LIST.slice(0, 600))
|
||
}
|
||
this.loading = false
|
||
}, 300)
|
||
},
|
||
mounted () {
|
||
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
|
||
hljs.highlightBlock(block)
|
||
})
|
||
}
|
||
}
|
||
</script>
|