Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

vue组件父传子有关echart颜色问题

问题:在做echart视图的时候,有多个柱状图。只是颜色不一样。现在想在父组件上添加一个:barColor这样的属性,通过父组件单独定义颜色传给子组件。
p.s.最好不是那种颜色数组解决办法,var color =["#...","#..."],

父:

<OrgBar :monID="curTimeStr" :orgID="ORGID" :barColor=""/>

子:

 props: {
    barColor: String,
 },
  
orgBarEchart(){
    var colorBar = "";
    var option = {
       .......
       color:"colorBar"
    }
}

以上的办法不显示,报错。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

???
image.png
这里你给color赋值字符串干嘛,要用prop传过来的值是this.colorBar,prop传过来的值都绑定在vue实例里面也就是this上面


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...