vue中父组件传值给子组件,父组件值改变,子组件不能重新渲染
在子组件中用watch()监听值的改变,不同的类型的要用不同的监听方法props: {echartStyle: {type: Object,default() {return {}}},titleText: {type: String,default: ''},tooltipFormatter: {type: String,default: ''},
·
在子组件中用watch()监听值的改变,不同的类型的要用不同的监听方法
props: {
echartStyle: {
type: Object,
default() {
return {}
}},
titleText: {
type: String,
default: ''
},
tooltipFormatter: {
type: String,
default: ''
},
opinion: {
type: Array,
default() {
return []
}
},
seriesName: {
type: String,
default: ''
},
opinionData: {
type: Array,
default() {
return []
}
}
}
watch进行监听
watch:{
titleText:function(newValue,oldValue){
this.getChange();
},
echartStyle:{
handler(newValue,oldValue){
this.getChange();
},
deep:true
},
tooltipFormatter:function(newValue,oldValue){
this.getChange();
},
opinion:{
handler(newValue,oldValue){
this.getChange();
},
deep:true //深度监听
},
seriesName:function(newValue,oldValue){
this.getChange();
},
opinionData:{
handler(newValue,oldValue){
this.getChange();
},
deep:true
}
},
更多推荐
已为社区贡献27条内容
所有评论(0)