Files
vxe-table/examples/views/table/grid/Basic.vue
xuliangzhan 1ad4d49371 更新文档
2019-12-07 10:26:23 +08:00

100 lines
2.8 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"/> 高级表格解决动态数据一切需求动态列动态数据动态个性化...<br>
渲染性能对比<grid-api-link name="vxe-grid"/>性能最优不需要为每一列创建实例 > <table-api-link name="vxe-table"/>性能略差需要为每一列创建实例<br>
通过 <grid-api-link prop="columns"/> 动态配置列信息这非常适用于动态渲染的场景完全使用数据进行配置
</p>
<vxe-grid
border
resizable
toolbar
height="300"
:align="allAlign"
:loading="loading"
:columns="tableColumn"
:data="tableData">
<template v-slot: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 hljs from 'highlight.js'
export default {
data () {
return {
allAlign: null,
loading: false,
tableColumn: [
{ type: 'index', 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"
:loading="loading"
:columns="tableColumn"
:data="tableData"></vxe-grid>
`,
`
export default {
data () {
return {
allAlign: null,
loading: false,
tableColumn: [
{ type: 'index', 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
this.$ajax.mockList(50).then(data => {
this.tableData = data
this.loading = false
})
}
}
`
]
}
},
created () {
this.loading = true
this.$ajax.mockList(50).then(data => {
this.tableData = data
this.loading = false
})
},
mounted () {
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
hljs.highlightBlock(block)
})
}
}
</script>