nod svg 没有 height ava rip ram circle repl
在svg文件里定义控件,带参数,然后引用。
如果是 text 且没有为其它添加默认值,那么会报错。
即,
- <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0,0,200,200">
- <g>
- <circle r="100" cx="100" cy="100" style="fill:blue"/>
- <text x="50%" y="50%" alignment-baseline="middle" text-anchor="middle" content-value="param(key)"/>
- </g>
- <script type="text/javascript" xlink:href="lib/param.js" />
- </svg>
调用这个文件时会报错。原因就是text 没有赋默认值。
修改 param.js 的148行为:
- if (el.firstChild) {
- el.replaceChild(document.createTextNode(newVal), el.firstChild);
- } else {
- el.appendChild(document.createTextNode(newVal));
- }
即可
svg param.js的大bug
nod svg 没有 height ava rip ram circle repl
原文:http://www.cnblogs.com/goldli/p/7797869.html
来源: http://www.bubuko.com/infodetail-2383867.html