根据 JSON 数据,用 JavaScript 旋转风玫瑰图标

Rotate wind rose icon with JavaScript based on JSON data

Sandbox link.

我正在尝试旋转静态罗盘图标(称为 towards-0-deg / f0b1)以反映风向。

我尝试了 windRose = iconRotate.rotate(data.weather.deg); 和后来的 windElement.innerHTML = ` ${windRose.rotate(data.weather.deg)}` + `${weather.wind} km/h`; 但我得到:未捕获(承诺)ReferenceError: iconRotate is not defined.

我做错了什么?

我设法像这样修复它:

      weather.rose = function(){
    $(".wi-wind").addClass("from-" + windDirection + "-deg")
    setTimeout(function (){
      $("#roseIcon").removeClass();
      setTimeout(function () { 
      $("#roseIcon").addClass(`wi` +` `+ `wi-wind` +` `+ `from-` + windDirection + `-deg`)}, 1000)
    },920000)
  };