mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
92 lines
2.7 KiB
Vue
92 lines
2.7 KiB
Vue
<template>
|
||
<div>
|
||
<p class="tip">
|
||
当一个表格高度需要自适应的时候可以通过 <table-api-link prop="max-height"/> 设置为最大高度<br>
|
||
<span class="red">(注:树结构不支持大量数据,如果数据量超过 500 条,请谨慎使用!)</span>
|
||
</p>
|
||
|
||
<vxe-toolbar>
|
||
<template v-slot:buttons>
|
||
<vxe-button @click="$refs.xTree.setAllTreeExpand(true)">展开所有</vxe-button>
|
||
<vxe-button @click="$refs.xTree.clearTreeExpand()">关闭所有</vxe-button>
|
||
</template>
|
||
</vxe-toolbar>
|
||
|
||
<vxe-table
|
||
border
|
||
resizable
|
||
ref="xTree"
|
||
max-height="400"
|
||
:tree-config="{children: 'children'}"
|
||
:data="tableData">
|
||
<vxe-table-column field="name" title="app.body.label.name" tree-node></vxe-table-column>
|
||
<vxe-table-column field="size" title="Size"></vxe-table-column>
|
||
<vxe-table-column field="type" title="Type"></vxe-table-column>
|
||
<vxe-table-column field="date" title="Date"></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>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import XEUtils from 'xe-utils'
|
||
import hljs from 'highlight.js'
|
||
|
||
export default {
|
||
data () {
|
||
return {
|
||
tableData: [],
|
||
demoCodes: [
|
||
`
|
||
<vxe-toolbar>
|
||
<template v-slot:buttons>
|
||
<vxe-button @click="$refs.xTree.setAllTreeExpand(true)">展开所有</vxe-button>
|
||
<vxe-button @click="$refs.xTree.clearTreeExpand()">关闭所有</vxe-button>
|
||
</template>
|
||
</vxe-toolbar>
|
||
|
||
<vxe-table
|
||
border
|
||
resizable
|
||
ref="xTree"
|
||
max-height="400"
|
||
:tree-config="{children: 'children'}"
|
||
:data="tableData">
|
||
<vxe-table-column field="name" title="app.body.label.name" tree-node></vxe-table-column>
|
||
<vxe-table-column field="size" title="Size"></vxe-table-column>
|
||
<vxe-table-column field="type" title="Type"></vxe-table-column>
|
||
<vxe-table-column field="date" title="Date"></vxe-table-column>
|
||
</vxe-table>
|
||
`,
|
||
`
|
||
export default {
|
||
data () {
|
||
return {
|
||
tableData: []
|
||
}
|
||
},
|
||
created () {
|
||
this.tableData = window.MOCK_TREE_DATA_LIST
|
||
}
|
||
}
|
||
`
|
||
]
|
||
}
|
||
},
|
||
created () {
|
||
this.tableData = XEUtils.clone(window.MOCK_TREE_DATA_LIST, true)
|
||
},
|
||
mounted () {
|
||
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
|
||
hljs.highlightBlock(block)
|
||
})
|
||
}
|
||
}
|
||
</script>
|