我在网页上内嵌了以下SVG图像:
const svg = document.getElementById(‘svg’);const filter = document.createElementNS(’http://www.w3.org/2000/svg','filter');过滤….
你需要使用: 的 与Document.createElementNS(...) 强> 对于svg元素,在这种情况下 的 setAttributeNS(...) 强> 以及;
例如改变:
const filter = document.createElement('filter');
至
const filter = document.createElementNS('http://www.w3.org/2000/svg', 'filter');
另外更改:
feImage.setAttribute('xlink:href', 'http://lorempixel.com/100/100/');
feImage.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'http://lorempixel.com/100/100/');
小提琴