我試圖通過Snap.svg在svg中追加/寫入文本。下面的代碼在Chrome,Firefox,Opera和Edge中工作正常,但不能在Internet Explorer中工作。我曾嘗試把字符集作爲utf8放在html文件中的元標記中,但它仍然不起作用。Internet Explorer中svg文本中的空白位置
如果lines2作爲參數傳遞,那麼Internet Explorer會將 視爲普通字符串。
var lines1 = ["a b", "c d", "e f"];
var lines2 = ["a b", "c d", "e f"];
Snap("#svg").text(10, 0, lines).attr({
fill: "black",
fontSize: "18px"
}).selectAll("tspan").forEach(function(tspan, i) {
tspan.attr({
x: 0,
dy: 20
});
tspan.node.innerHTML = tspan.node.textContent.replace(/ /g,' ');
});
這是一個jsfiddle的鏈接。
它的工作!謝謝.... –