Svg 文本在 safari 和 IE 中不起作用,但在 chrome 和 firefox 中可以正常工作

Svg text is not working in safari and IE however it work's fine with chrome and firefox

 text[i + 1] = document.createElementNS("http://www.w3.org/2000/svg", "text");
            text[i + 1].setAttribute('x', legendX[i + 1] - 15);
            text[i + 1].setAttribute('y', legendY[i + 1] + 30);
            text[i + 1].setAttribute('style', "fill;red");
            text[i + 1].id = "text" + (i + 1);
            svgmain.appendChild(text[i + 1]);
            document.getElementById(text[i + 1].id).innerHTML = yearAllTimelineDates[i + 1][1].toString().substring(0, 4);

// 所以我使用 innerHTML 属性 来设置文本值

使用这个,

document.getElementById(text[i + 1].id).textContent= yearAllTimelineDates[i + 1][1].toString().substring(0, 4);