Files
vxe-table/examples/views/table/base/Empty.vue
xuliangzhan b99cee0652 update
2019-08-28 23:29:26 +08:00

153 lines
4.5 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">基础使用</p>
<vxe-table
:data="tableData">
<vxe-table-column type="index" width="60"></vxe-table-column>
<vxe-table-column field="name" title="Name"></vxe-table-column>
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
<vxe-table-column field="age" title="Age"></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>
<p class="tip">出现滚动条</p>
<vxe-table
border
:data="tableData">
<vxe-table-column type="index" width="100"></vxe-table-column>
<vxe-table-column field="name" title="Name" width="300"></vxe-table-column>
<vxe-table-column field="sex" title="Sex" width="300"></vxe-table-column>
<vxe-table-column field="date" title="Date" width="300"></vxe-table-column>
<vxe-table-column field="age" title="Age" width="300"></vxe-table-column>
<vxe-table-column field="address" title="Address" width="300" show-overflow></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>
<p class="tip">配合 loading 使用可以通过 slot=<table-api-link prop="empty"/> 自定义提示语</p>
<vxe-table
border
height="300"
:loading="loading"
:data="tableData">
<vxe-table-column type="index" width="60"></vxe-table-column>
<vxe-table-column field="name" title="Name"></vxe-table-column>
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
<vxe-table-column field="age" title="Age"></vxe-table-column>
<vxe-table-column field="address" title="Address" show-overflow></vxe-table-column>
<template v-slot:empty>
<span style="color: red;">没有更多数据了</span>
</template>
</vxe-table>
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
<pre>
<code class="xml">{{ demoCodes[2] }}</code>
<code class="javascript">{{ demoCodes[3] }}</code>
</pre>
</div>
</template>
<script>
import hljs from 'highlight.js'
export default {
data () {
return {
loading: false,
tableData: [],
tableData2: [],
demoCodes: [
`
<vxe-table
:data="tableData">
<vxe-table-column type="index" width="60"></vxe-table-column>
<vxe-table-column field="name" title="Name"></vxe-table-column>
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
<vxe-table-column field="age" title="Age"></vxe-table-column>
</vxe-table>
`,
`
export default {
data () {
return {
loading: false,
tableData: [],
tableData2: []
}
},
created () {
setTimeout(() => {
this.tableData = []
}, 1000)
}
}
`,
`
<vxe-table
:loading="loading"
:data="tableData2">
<vxe-table-column type="index" width="60"></vxe-table-column>
<vxe-table-column field="name" title="Name"></vxe-table-column>
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
<vxe-table-column field="age" title="Age"></vxe-table-column>
<vxe-table-column field="address" title="Address" show-overflow></vxe-table-column>
<template v-slot:empty>
<span style="color: red;">没有更多数据了!</span>
</template>
</vxe-table>
`,
`
export default {
data () {
return {
loading: false,
tableData: [],
tableData2: []
}
},
created () {
this.loading = true
setTimeout(() => {
this.loading = false
this.tableData2 = []
}, 1000)
}
}
`
]
}
},
created () {
setTimeout(() => {
this.tableData = []
}, 1000)
this.loading = true
setTimeout(() => {
this.loading = false
this.tableData2 = []
}, 1000)
},
mounted () {
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
hljs.highlightBlock(block)
})
}
}
</script>