mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
129 lines
3.7 KiB
Vue
129 lines
3.7 KiB
Vue
<template>
|
|
<div>
|
|
<p class="tip">使用自定义模板渲染</p>
|
|
|
|
<vxe-toolbar>
|
|
<template v-slot:buttons>
|
|
<vxe-input size="small" placeholder="搜索"></vxe-input>
|
|
</template>
|
|
<template v-slot:tools>
|
|
<vxe-button status="primary">操作1</vxe-button>
|
|
<vxe-button status="primary">操作2</vxe-button>
|
|
<vxe-button status="primary">操作3</vxe-button>
|
|
</template>
|
|
</vxe-toolbar>
|
|
|
|
<vxe-table
|
|
border
|
|
resizable
|
|
:tree-config="{children: 'children'}"
|
|
:data="tableData">
|
|
<vxe-table-column field="name" title="app.body.label.name"></vxe-table-column>
|
|
<vxe-table-column field="size" title="Size"></vxe-table-column>
|
|
<vxe-table-column field="type" title="Type">
|
|
<template v-slot="{ row }">
|
|
<span>{{ `类型:${row.type || '无'}` }}</span>
|
|
</template>
|
|
</vxe-table-column>
|
|
<vxe-table-column field="type" title="Image" tree-node>
|
|
<template>
|
|
<img src="static/other/img1.gif" height="50">
|
|
</template>
|
|
</vxe-table-column>
|
|
<vxe-table-column field="date" title="Date">
|
|
<template v-slot="{ row }">
|
|
<span>{{ formatDate(row.date) }}</span>
|
|
</template>
|
|
</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-toolbar>
|
|
<template v-slot:buttons>
|
|
<vxe-input size="small" placeholder="搜索"></vxe-input>
|
|
</template>
|
|
<template v-slot:tools>
|
|
<vxe-button status="primary">操作1</vxe-button>
|
|
<vxe-button status="primary">操作2</vxe-button>
|
|
<vxe-button status="primary">操作3</vxe-button>
|
|
</template>
|
|
</vxe-toolbar>
|
|
|
|
<vxe-table
|
|
border
|
|
resizable
|
|
:tree-config="{children: 'children'}"
|
|
:data="tableData">
|
|
<vxe-table-column field="name" title="app.body.label.name"></vxe-table-column>
|
|
<vxe-table-column field="size" title="Size"></vxe-table-column>
|
|
<vxe-table-column field="type" title="Type">
|
|
<template v-slot="{ row }">
|
|
<span>{{ \`类型:\${row.type || '无'}\` }}</span>
|
|
</template>
|
|
</vxe-table-column>
|
|
<vxe-table-column field="type" title="Image" tree-node>
|
|
<template>
|
|
<img src="static/other/img1.gif" height="50">
|
|
</template>
|
|
</vxe-table-column>
|
|
<vxe-table-column field="date" title="Date">
|
|
<template v-slot="{ row }">
|
|
<span>{{ formatDate(row.date) }}</span>
|
|
</template>
|
|
</vxe-table-column>
|
|
</vxe-table>
|
|
`,
|
|
`
|
|
export default {
|
|
data () {
|
|
return {
|
|
tableData: []
|
|
}
|
|
},
|
|
created () {
|
|
this.tableData = window.MOCK_TREE_DATA_LIST.slice(0)
|
|
},
|
|
methods: {
|
|
formatDate (value) {
|
|
return XEUtils.toDateString(value, 'yyyy-MM-dd HH:mm:ss.S')
|
|
}
|
|
}
|
|
}
|
|
`
|
|
]
|
|
}
|
|
},
|
|
created () {
|
|
this.tableData = XEUtils.clone(window.MOCK_TREE_DATA_LIST, true)
|
|
},
|
|
mounted () {
|
|
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
|
|
hljs.highlightBlock(block)
|
|
})
|
|
},
|
|
methods: {
|
|
formatDate (value) {
|
|
return XEUtils.toDateString(value, 'yyyy-MM-dd HH:mm:ss.S')
|
|
}
|
|
}
|
|
}
|
|
</script>
|