以cax方式加载svg只能使用renderSvg(html`svg`,'svg-a',this)这种方式吗?
dyj11 opened this issue · comments
let mD = <svg width="300" height="300"> <rect bindtap="tapHandler" x="0" y="0" height="110" width="110" style="stroke:#ff0000; fill: #0000ff" /> <rect bindtap="tapHandler" x="0" y="0" height="110" width="110" style="stroke:#ff0000; fill: #0000ff" /> </svg>
;
const svg = renderSVG(html${mD}
, 'svg-a', this)
console.log('children:' + svg.children.length)
是的。这样不行,因为这样解不出虚拟节点。https://github.com/developit/htm
需要:
html`<svg>xxxx</svg>`
当然你也可以 hypescript 的方式加载和书写。
h('svg', xxx, xxx)
是的。这样不行,因为这样解不出虚拟节点。https://github.com/developit/htm
需要:
html`<svg>xxxx</svg>`
当然你也可以 hypescript 的方式加载和书写。
h('svg', xxx, xxx)
请问下,为什么我这样做不行呢?原理是什么呢?还有就是采用hypescript的方式可以在小程序里面使用吗?
可以深入学习下 template string
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/template_strings
可以深入学习下 template string
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/template_strings
感谢解答