mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
119 lines
3.8 KiB
Vue
119 lines
3.8 KiB
Vue
<template>
|
||
<div>
|
||
<p>通过给需要排序功能的列加上 <table-api-link prop="sortable"/> 属性可以支持排序,还可以通过设置 <table-api-link prop="sort-by"/> 多字段进行排序</p>
|
||
<p>如果是服务端排序,只需加上 <table-column-api-link prop="remote-sort"/> 和 <table-api-link prop="sort-change"/> 事件就可以实现</p>
|
||
|
||
<vxe-table
|
||
border
|
||
highlight-hover-row
|
||
height="300"
|
||
:data.sync="tableData">
|
||
<vxe-table-column type="index" width="60"></vxe-table-column>
|
||
<vxe-table-column field="name" title="Name" sortable></vxe-table-column>
|
||
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
|
||
<vxe-table-column field="age" title="Age"></vxe-table-column>
|
||
<vxe-table-column field="time" title="Time" sortable></vxe-table-column>
|
||
</vxe-table>
|
||
|
||
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
|
||
|
||
<pre>
|
||
<code class="xml">{{ demoCodes[0] }}</code>
|
||
<code class="javascript">{{ demoCodes[1] }}</code>
|
||
</pre>
|
||
|
||
<p>配置 <table-column-api-link prop="sort-by"/> 多个字段组合排序</p>
|
||
|
||
<vxe-table
|
||
border
|
||
highlight-hover-row
|
||
height="300"
|
||
:data.sync="tableData">
|
||
<vxe-table-column type="index" width="60"></vxe-table-column>
|
||
<vxe-table-column field="name" title="Name" sortable></vxe-table-column>
|
||
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
|
||
<vxe-table-column field="age" title="Age"></vxe-table-column>
|
||
<vxe-table-column field="time" title="Time" sortable :sort-by="['time', 'name']"></vxe-table-column>
|
||
</vxe-table>
|
||
|
||
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
|
||
|
||
<pre>
|
||
<code class="xml">{{ demoCodes[2] }}</code>
|
||
<code class="javascript">{{ demoCodes[3] }}</code>
|
||
</pre>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import hljs from 'highlight.js'
|
||
|
||
export default {
|
||
data () {
|
||
return {
|
||
tableData: [],
|
||
demoCodes: [
|
||
`
|
||
<vxe-table
|
||
border
|
||
highlight-hover-row
|
||
height="300"
|
||
:data.sync="tableData">
|
||
<vxe-table-column type="index" width="60"></vxe-table-column>
|
||
<vxe-table-column field="name" title="Name" sortable></vxe-table-column>
|
||
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
|
||
<vxe-table-column field="age" title="Age"></vxe-table-column>
|
||
<vxe-table-column field="time" title="Time" sortable></vxe-table-column>
|
||
</vxe-table>
|
||
`,
|
||
`
|
||
export default {
|
||
data () {
|
||
return {
|
||
tableData: []
|
||
}
|
||
},
|
||
created () {
|
||
this.tableData = window.MOCK_DATA_LIST.slice(0, 50)
|
||
}
|
||
}
|
||
`,
|
||
`
|
||
<vxe-table
|
||
border
|
||
highlight-hover-row
|
||
height="300"
|
||
:data.sync="tableData">
|
||
<vxe-table-column type="index" width="60"></vxe-table-column>
|
||
<vxe-table-column field="name" title="Name" sortable></vxe-table-column>
|
||
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
|
||
<vxe-table-column field="age" title="Age"></vxe-table-column>
|
||
<vxe-table-column field="time" title="Time" sortable :sort-by="['time', 'name']"></vxe-table-column>
|
||
</vxe-table>
|
||
`,
|
||
`
|
||
export default {
|
||
data () {
|
||
return {
|
||
tableData: []
|
||
}
|
||
},
|
||
created () {
|
||
this.tableData = window.MOCK_DATA_LIST.slice(0, 50)
|
||
}
|
||
}
|
||
`
|
||
]
|
||
}
|
||
},
|
||
created () {
|
||
this.tableData = window.MOCK_DATA_LIST.slice(0, 50)
|
||
},
|
||
mounted () {
|
||
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
|
||
hljs.highlightBlock(block)
|
||
})
|
||
}
|
||
}
|
||
</script>
|