Files
vxe-table/examples/views/table/grid/Basic.vue
xuliangzhan 81ce4246d6 更新文档
2020-08-13 19:03:26 +08:00

108 lines
3.2 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 prop="columns"/> json化配置列信息这非常适用于动态渲染的场景再配合 <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>