Files
vxe-table/examples/views/table/scroll/Highlight.vue
xuliangzhan 44f91141ae 工程优化
2020-02-21 18:19:51 +08:00

112 lines
3.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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>