我在飞行中改变特征颜色,我在vue
的mounted
末尾使用这个函数
existingFeatures.value.forEach(feature => {
const color = "red"
feature.setStyle(new Style({
stroke: new Stroke({color: color}),
fill: new Fill({color: color})
}));
})
由于某些原因,功能在更新后会消失
答案:setStyle()
将覆盖所有样式,所以我需要设置描边和半径
style.getImage().getFill().setColor(color);
style.getImage().getStroke().setColor(color);
style.getImage().setRadius(5)