1.安装 echart
链接到标题
1
| npm install native-echarts --save
|
1
| import Echarts from 'native-echarts';
|
3.把option封装成函数
链接到标题
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| echart(val,title){
option = {
tooltip: {
formatter: '{a} <br/>{b} : {c}%'
},
series: [
{
name: 'Pressure',
type: 'gauge',
detail: {
formatter: '{value}'
},
data: [
{
value: val,
name: title
}
]
}
]
};
return option
}
|
1
| <Echarts option={this.echart(this.start.title,this.state.val)} height={420} />
|
在miot-plugin-sdk里面,如果不封装成函数,传不进去值,别的办法没去想,就这么用吧。组件里的高度和大小可以自己根据文档调试。