Files
vxe-table/examples/views/table/scroll/KeepAlives.vue
xuliangzhan c181cd1fda 更新文档
2020-01-09 18:11:47 +08:00

66 lines
1.9 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">
keep-alive 切换<span class="red">如果需要将表格放到隐藏的元素中那么就必然会导致宽度无法计算</span>有以下方法解决<br>
1.每次切换 Tab 页显示之后手动调用 <table-api-link prop="recalculate"/> 重新计算宽度<br>
2.使用 <table-api-link prop="sync-resize"/> 绑定可视的变量实现自动更新宽度<br>
3.使用 <table-api-link prop="auto-resize"/> 自动监听响应式更新宽度
</p>
<p class="btns">
<router-link class="link" :to="{name: 'TableScrollKeepAliveTable1'}">表格1</router-link>
<router-link class="link" :to="{name: 'TableScrollKeepAliveTable2'}">表格2</router-link>
<router-link class="link" :to="{name: 'TableScrollKeepAliveTable3'}">表格3</router-link>
</p>
<keep-alive>
<router-view></router-view>
</keep-alive>
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
<pre>
<code class="xml">{{ demoCodes[0] }}</code>
</pre>
</div>
</template>
<script>
import hljs from 'highlight.js'
export default {
data () {
return {
demoCodes: [
`
<p class="btns">
<router-link class="link" :to="{name: 'TableKeepAliveTable1'}">表格1</router-link>
<router-link class="link" :to="{name: 'TableKeepAliveTable2'}">表格2</router-link>
<router-link class="link" :to="{name: 'TableKeepAliveTable3'}">表格3</router-link>
</p>
<keep-alive>
<router-view></router-view>
</keep-alive>
`
]
}
},
mounted () {
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
hljs.highlightBlock(block)
})
}
}
</script>
<style scoped>
.btns .link {
margin-right: 20px;
color: #333;
}
.btns .link.router-link-exact-active {
color: #409eff;
}
</style>