启明星在这里 2019-04-22 15:17 采纳率: 0%
浏览 2742

js创建div,class样式无效

在vue里创建div,给一个class,渲染到openlayers地图上,css里给class添加动画不生效

var point_div = document.createElement("div");
point_div.className = "anchorImg";
point_overlay = new ol.Overlay({
        element: point_div,
        positioning: "bottom-center"
      });
      map.addOverlay(point_overlay);
      point_overlay.setPosition(coor);
    })

css动画

.anchorImg {
  height: 50px;
  width: 50px;
  border-radius: 25px;
  background: rgba(255, 0, 0, 1);
  transform: scale(0);
  animation: myfirst 2s;
  animation-iteration-count: infinite;
}

@keyframes myfirst {
  to {
    transform: scale(2);
    background: rgba(0, 0, 0, 0);
  }
}
  • 写回答

3条回答 默认 最新

  • sinat_39403108 2019-04-22 17:00
    关注

    point_div.className = "anchorImg";vue里面不是className,直接point_div.class = "anchorImg";或者point_div.style="你的style布局"

    评论

报告相同问题?