ES6中的字符串新方法padStart()来填充字符串
1.从开始填充: String.Prototype.padStart(maxLength,fillString=’’)//maxLength :填充后的字符串的位数,fillString:填充的字符。
2.从尾部填充:String.prototype.padEnd(maxLength,fillString=’’)
3.
function getColor(){
var col = “#”;
for(var i=0;i<3;i++){
col += Math.floor(Math.random()*256).toString(16).padStart(2,0);
}
return col;
},
var res = getColor()
console.log(res)
4.循环产生不同的echarts时,需要展示不同的颜色 就可以用到上面的方法
5 series: [
{
name: that.chartData[i].depict,
type: 'line',
smooth: true,
symbol: 'none',
lineStyle:{
color:this.getColor()
},
areaStyle: {
opacity:0.1,
color:'#fff'
},
data: data
}
]
6.