是因为数据没有取到就切换别的页面,造成dom渲染失效导致,需要利用v-if和页面生命周期进行判断
//html
<view v-if="chartShow">
...
</view>
//data
chartShow: true, // 图表
chartOption:{}, // 图表数据
chartSeries: null, // 判断是否加载图表
//js
// 图表
getChartOption(){
调接口....
this.chartOption = {
........
}
},
// 每次页面显示
onShow() {
if (!this.chartSeries) {
this.chartShow= true
this.$nextTick(() => {
this.getChartOption() // 加载图表
});
}
},
// 每次页面隐藏
onHide() {
this.chartSeries= this.timeBatterLineOption.series // 接收数据
if (!this.timeBatterLineOption.series) {
this.timeBatterLineOptionShow = false
}
},
onReady() {
},
上一篇文章,