let labelClass = 'warning'
let labelText = "<div class='"+labelClass+"'>"+element.text+"</br>实时功率:"+res.info.power+"KW</br>负荷率:"+rate+"%</div>";
let label = new BMap.Label(labelText, opts);
label.setStyle({
fontSize : "10px",
lineHeight : "16px",
padding:0,
border:'none',
});
map.addOverlay(label);
重要的是@deep
<style lang="less" scoped>
@deep: ~'>>>';
@{deep}.warning{
background: #f5726b;
border: 1px solid #a6322d;
padding-left: 3px;
}
@{deep}.warning::before{
content: '';
display: block;
width: 110px;
height: 3px;
margin-bottom: 3px;
margin-left: -3px;
background: #7d2622;
animation: twinkling 1s linear;
-webkit-animation: twinkling 1s linear;
animation-iteration-count:infinite;
-webkit-animation-iteration-count:infinite;
}
@-webkit-keyframes twinkling{
0%{
opacity: 1;
}
50%{
opacity: 0;
}
100%{
opacity: 1;
}
}
@keyframes twinkling{
0%{
opacity: 1;
}
100%{
opacity: 1;
}
}
</style>