Tencent / omi

Web Components Framework - Web组件框架

Home Page:http://omijs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

以cax方式加载svg只能使用renderSvg(html`svg`,'svg-a',this)这种方式吗?

dyj11 opened this issue · comments

commented

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)

为什么我使用这种方式加载svg,无法渲染svg。因为项目需要加载外部svg
svgError

是的。这样不行,因为这样解不出虚拟节点。https://github.com/developit/htm

需要:

html`<svg>xxxx</svg>`

当然你也可以 hypescript 的方式加载和书写。

h('svg', xxx, xxx)
commented

是的。这样不行,因为这样解不出虚拟节点。https://github.com/developit/htm

需要:

html`<svg>xxxx</svg>`

当然你也可以 hypescript 的方式加载和书写。

h('svg', xxx, xxx)

请问下,为什么我这样做不行呢?原理是什么呢?还有就是采用hypescript的方式可以在小程序里面使用吗?