Files
vxe-table/examples/views/table/grid/Basic.vue
xuliangzhan ff919b3ade 更新文档
2020-05-27 21:22:51 +08:00

108 lines
3.3 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">
<grid-api-link name="vxe-grid"/> 高级表格基于 <table-api-link name="vxe-table"/> 封装解决动态数据一切需求动态列动态数据动态个性化...<br>
通过 <grid-api-link prop="columns"/> 动态配置列信息这非常适用于动态渲染的场景完全使用数据进行配置再配合 <router-link class="link" :to="{name: 'GridConfigProxy'}">数据代理</router-link> 甚至可以非常简单的用一个 json 数据就能渲染完整表格
</p>
<vxe-grid
border
resizable
height="300"
:align="allAlign"
:loading="loading"
:columns="tableColumn"
:toolbar="{slots: {buttons: 'toolbar_buttons'}}"
:data="tableData">
<template v-slot:toolbar_buttons>
<vxe-button @click="allAlign = 'left'">居左</vxe-button>
<vxe-button @click="allAlign = 'center'">居中</vxe-button>
<vxe-button @click="allAlign = 'right'">居右</vxe-button>
</template>
</vxe-grid>
<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 XEAjax from 'xe-ajax'
import hljs from 'highlight.js'
export default {
data () {
return {
allAlign: null,
loading: false,
tableColumn: [
{ type: 'seq', width: 50 },
{ field: 'name', title: 'app.body.label.name' },
{ field: 'sex', title: 'app.body.label.sex', showHeaderOverflow: true },
{ field: 'address', title: 'Address', showOverflow: true }
],
tableData: [],
demoCodes: [
`
<vxe-grid
border
resizable
height="300"
:align="allAlign"
:loading="loading"
:columns="tableColumn"
:toolbar="{slots: {buttons: 'toolbar_buttons'}}"
:data="tableData">
<template v-slot:toolbar_buttons>
<vxe-button @click="allAlign = 'left'">居左</vxe-button>
<vxe-button @click="allAlign = 'center'">居中</vxe-button>
<vxe-button @click="allAlign = 'right'">居右</vxe-button>
</template>
</vxe-grid>
`,
`
export default {
data () {
return {
allAlign: null,
loading: false,
tableColumn: [
{ type: 'seq', width: 50 },
{ field: 'name', title: 'app.body.label.name' },
{ field: 'sex', title: 'app.body.label.sex', showHeaderOverflow: true },
{ field: 'address', title: 'Address', showOverflow: true }
],
tableData: []
}
},
created () {
this.loading = true
XEAjax.mockList(50).then(data => {
this.tableData = data
this.loading = false
})
}
}
`
]
}
},
created () {
this.loading = true
XEAjax.mockList(50).then(data => {
this.tableData = data
this.loading = false
})
},
mounted () {
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
hljs.highlightBlock(block)
})
}
}
</script>