报Cannot read properties of null (reading ‘appendChild’)
因为是这个页面是使用了@antv/g2,canvas绘图。当快速切切换页面时,由于canvas绘图使用的是数据为空数组,所以会报错
因此在进行渲染canvas的之前,需要判断下:canvas绘图使用的数据是否为空数组。
watch: {
dt: {
handler(val) {
// 只有在dt有数据的时候才会渲染图表,否则会报错:Cannot read properties of null (reading 'appendChild')
if (val.length) {
// 开始绘图渲染
this.init()
}
},
deep: true,
immediate: true,
},
},