vue修改echart图表子组件属性值后子组件不重新渲染的问题
使用watch监听属性变量
export default {
mixins: [resize],
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '300px'
},
ageData:{
default: [],
type: Array
}
},
watch:{
ageData:{
deep:true,
handler:function(newVal,oldVal){
console.log("传入图表的新值",newVal)
if(newVal){
this.ageData=newVal
this.initChart(newVal);
}
}
}
},

本文探讨了在Vue项目中使用ECharts时遇到的子组件数据更新后不重新渲染的问题,并提供了解决方案。通过深入分析,我们了解到使用watch监听属性变化并重新初始化图表可以确保视图的实时更新。
3649

被折叠的 条评论
为什么被折叠?



