Files
vxe-table/examples/views/table/tree/Expand.vue
xuliangzhan 0d3e5b33de 更新文档
2019-12-30 20:13:33 +08:00

107 lines
2.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">树表格与展开行同时使用非常简单就能实现很复杂的树形展开行</p>
<vxe-table
border
resizable
:tree-config="{children: 'children'}"
:data="tableData">
<vxe-table-column field="name" title="Name" tree-node></vxe-table-column>
<vxe-table-column type="expand" title="Details" width="80">
<template v-slot:content="{ row, rowIndex }">
<ul>
<li>
<span>ID</span>
<span>{{ row.id }}</span>
</li>
<li>
<span>Name</span>
<span>{{ row.name }}</span>
</li>
<li>
<span>Date</span>
<span>{{ row.date }}</span>
</li>
</ul>
</template>
</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-table
border
resizable
:tree-config="{children: 'children'}"
:data="tableData">
<vxe-table-column field="name" title="Name" tree-node></vxe-table-column>
<vxe-table-column type="expand" width="60">
<template v-slot:content="{ row, rowIndex }">
<ul>
<li>
<span>ID</span>
<span>{{ row.id }}</span>
</li>
<li>
<span>Name</span>
<span>{{ row.name }}</span>
</li>
<li>
<span>Date</span>
<span>{{ row.date }}</span>
</li>
</ul>
</template>
</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.slice(0)
}
}
`
]
}
},
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>