Why doesn't this arrow function work in IE 11?

后端 未结 4 1366
暖寄归人
暖寄归人 2020-11-22 00:12

Below piece of code does not work in IE 11, it throws a syntax error in the console

g.selectAll(\".mainBars\")
    .append(\"text\")
    .attr(\"x\", d =>         


        
4条回答
  •  逝去的感伤
    2020-11-22 00:47

    Avoid use of arrow functions if you need to support IE 11 as it is not supported

    Change those to regular functions and your code should work as you expect

    g.selectAll(".mainBars").append("text").attr("x",function(d) { 
      return d.part=="primary"? -40: 40;
    }).attr("y",function(d){
      return +6;
    }).text(function(d) { 
      return d.key;
    }).attr("text-anchor", function(d) { 
      return d.part=="primary"? "end": "start";
    });
    

提交回复
热议问题