javascript - Property 'width' does not exist on type 'HTMLElement' -
the following typescript fails compile:
let svg = document.createelement("svg"); svg.width = 300; due error property 'width' not exist on type 'htmlelement'. if change svg canvas, example, compile, it's svgs seems...
any ideas?
let svg = document.createelement("svg"); doesn't create svg element, custom html element.
proper way create svg element:
let svg = document.createelementns("http://www.w3.org/2000/svg", "svg"); const customsvg = document.createelement("svg") const propersvg = document.createelementns("http://www.w3.org/2000/svg", "svg") console.log(customsvg instanceof svgsvgelement) // false console.log(propersvg instanceof svgsvgelement) // true console.log(customsvg.width) // undefined console.log(propersvg.width) // svganimatedlength {}
Comments
Post a Comment