消除红色图表未找到的警告和删除views下多余的vue文件
This commit is contained in:
@@ -39,7 +39,8 @@ export default {
|
||||
'rgba(153, 102, 255, 1)'
|
||||
],
|
||||
myChart: null, // 保存图表实例,便于销毁和缩放
|
||||
resizeHandler: null // 窗口resize事件处理器
|
||||
resizeHandler: null, // 窗口resize事件处理器
|
||||
isMounted: false // 图表挂载标志,避免过早执行
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
@@ -47,13 +48,14 @@ export default {
|
||||
// 监听 chartData 变化,只要数据变了,就更新图表
|
||||
chartData: {
|
||||
handler() {
|
||||
if (!this.isMounted) return; // 挂载前保护
|
||||
this.initData(); // 直接调用更新
|
||||
},
|
||||
deep: true, // 深度监听数组/对象变化
|
||||
immediate: true // 初始化时立即执行
|
||||
deep: true // 深度监听数组/对象变化
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.isMounted = true;
|
||||
this.$nextTick(() => {
|
||||
this.initData(); // 初始化图表
|
||||
});
|
||||
@@ -83,7 +85,7 @@ export default {
|
||||
|
||||
const chartDom = this.$refs[this.chartRef];
|
||||
if (!chartDom) {
|
||||
console.error(`图表容器未找到!请确认父组件传递的 chartRef 为 "${this.chartRef}"`);
|
||||
if (process.env.NODE_ENV === 'development') console.warn(`图表容器未找到!请确认父组件传递的 chartRef 为 "${this.chartRef}"`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user