mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
110 lines
3.1 KiB
Vue
110 lines
3.1 KiB
Vue
<template>
|
|
<div>
|
|
<p class="tip">具体兼容请查看 <a class="link" href="https://www.npmjs.com/package/vxe-table-plugin-export" target="_blank">vxe-table-plugin-export</a> 插件的 API</p>
|
|
|
|
<vxe-toolbar setting :export="tableExport"></vxe-toolbar>
|
|
|
|
<vxe-table
|
|
border
|
|
height="400"
|
|
:loading="loading"
|
|
:data="tableData">
|
|
<vxe-table-column type="index" width="60"></vxe-table-column>
|
|
<vxe-table-column field="name" title="app.body.label.name"></vxe-table-column>
|
|
<vxe-table-column field="role" title="Role"></vxe-table-column>
|
|
<vxe-table-column field="sex" title="app.body.label.sex"></vxe-table-column>
|
|
<vxe-table-column field="age" title="app.body.label.age"></vxe-table-column>
|
|
<vxe-table-column field="rate" title="Rate"></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 hljs from 'highlight.js'
|
|
|
|
export default {
|
|
data () {
|
|
return {
|
|
loading: false,
|
|
tableData: [],
|
|
tableExport: {
|
|
// 默认选中类型
|
|
type: 'xlsx',
|
|
// 自定义类型顺序
|
|
types: ['xlsx', 'csv', 'html', 'xml', 'txt']
|
|
},
|
|
demoCodes: [
|
|
`
|
|
<vxe-toolbar setting :export="tableExport"></vxe-toolbar>
|
|
|
|
<vxe-table
|
|
border
|
|
height="400"
|
|
:loading="loading"
|
|
:data="tableData">
|
|
<vxe-table-column type="index" width="60"></vxe-table-column>
|
|
<vxe-table-column field="name" title="app.body.label.name"></vxe-table-column>
|
|
<vxe-table-column field="role" title="Role"></vxe-table-column>
|
|
<vxe-table-column field="sex" title="app.body.label.sex"></vxe-table-column>
|
|
<vxe-table-column field="age" title="app.body.label.age"></vxe-table-column>
|
|
<vxe-table-column field="rate" title="Rate"></vxe-table-column>
|
|
</vxe-table>
|
|
`,
|
|
`
|
|
export default {
|
|
data () {
|
|
return {
|
|
loading: false,
|
|
tableData: [],
|
|
tableExport: {
|
|
// 默认选中类型
|
|
type: 'xlsx',
|
|
// 自定义类型顺序
|
|
types: ['xlsx', 'csv', 'html', 'xml', 'txt']
|
|
}
|
|
}
|
|
},
|
|
created () {
|
|
this.findList()
|
|
},
|
|
methods: {
|
|
findList () {
|
|
this.loading = true
|
|
setTimeout(() => {
|
|
this.tableData = window.MOCK_DATA_LIST.slice(0, 10)
|
|
this.loading = false
|
|
}, 100)
|
|
}
|
|
}
|
|
}
|
|
`
|
|
]
|
|
}
|
|
},
|
|
created () {
|
|
this.findList()
|
|
},
|
|
mounted () {
|
|
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
|
|
hljs.highlightBlock(block)
|
|
})
|
|
},
|
|
methods: {
|
|
findList () {
|
|
this.loading = true
|
|
setTimeout(() => {
|
|
this.tableData = window.MOCK_DATA_LIST.slice(0, 10)
|
|
this.loading = false
|
|
}, 100)
|
|
}
|
|
}
|
|
}
|
|
</script>
|