提交 2024d88a authored 作者: junjie's avatar junjie

refactor: 视图表格组件,渲染速度优化

上级 9917a9ef
......@@ -88,14 +88,12 @@ export default {
}
},
watch: {
chart() {
chart: function() {
this.init()
this.calcHeight()
}
},
mounted() {
this.init()
this.calcHeight()
// 监听元素变动事件
eventBus.$on('resizing', (componentId) => {
this.chartResize()
......@@ -103,6 +101,13 @@ export default {
},
methods: {
init() {
this.resetHeight()
this.$nextTick(() => {
this.initData()
this.calcHeightDelay()
})
},
initData() {
const that = this
let datas = []
if (this.chart.data) {
......@@ -117,12 +122,11 @@ export default {
this.initStyle()
})
window.onresize = function() {
that.calcHeight()
that.calcHeightDelay()
}
},
calcHeight() {
calcHeightRightNow() {
this.$nextTick(() => {
setTimeout(() => {
if (this.$refs.tableContainer) {
const currentHeight = this.$refs.tableContainer.offsetHeight
const tableMaxHeight = currentHeight - this.$refs.title.offsetHeight
......@@ -138,9 +142,13 @@ export default {
this.height = 'auto'
}
}
}, 100)
})
},
calcHeightDelay() {
setTimeout(() => {
this.calcHeightRightNow()
}, 100)
},
initStyle() {
if (this.chart.customAttr) {
const customAttr = JSON.parse(this.chart.customAttr)
......@@ -243,6 +251,10 @@ export default {
initClass() {
return this.chart.id
},
resetHeight() {
this.height = 100
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论