模具和SVG属性xlink href
在Stencil 1.8.0中,此代码起作用:模具和SVG属性xlink href,svg,stenciljs,Svg,Stenciljs,在Stencil 1.8.0中,此代码起作用: <svg> <use xlinkHref="#some-icon"/> </svg> 构建过程顺利通过,但在浏览器的控制台中,我得到: DOMException: Failed to execute 'setAttributeNS' on 'Element': The qualified name provided ('-href') contains the invalid name-start cha
<svg>
<use xlinkHref="#some-icon"/>
</svg>
构建过程顺利通过,但在浏览器的控制台中,我得到:
DOMException: Failed to execute 'setAttributeNS' on 'Element': The qualified name
provided ('-href') contains the invalid name-start character '-'.
at setAccessor (http://localhost:3334/build/index-a8bdf364.js:618:25)
at updateElement (http://localhost:3334/build/index-a8bdf364.js:646:9)
at createElm (http://localhost:3334/build/index-a8bdf364.js:695:13)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
我没有找到任何关于这方面的例子或文档
有人能告诉我如何解决这个问题吗?多亏了Slack上的Stencil chat中的Max,我才得到了答案。这是一个临时修复,而修复正在工作中
import { JSXBase } from '@stencil/core/internal';
// render()
type SVG2Attributes = JSXBase.SVGAttributes & { href: string };
// @ts-ignore
const link = <use href="example" /> as SVG2Attributes;
return (
<svg>
{link}
</svg>
);
从'@stencil/core/internal'导入{JSXBase};
//render()
键入SVG2Attributes=JSXBase.svgatattributes&{href:string};
//@ts忽略
常量链接=作为SVG2属性;
返回(
{link}
);
您可以链接到模具问题吗?谢谢
DOMException: Failed to execute 'setAttributeNS' on 'Element': The qualified name
provided ('-href') contains the invalid name-start character '-'.
at setAccessor (http://localhost:3334/build/index-a8bdf364.js:618:25)
at updateElement (http://localhost:3334/build/index-a8bdf364.js:646:9)
at createElm (http://localhost:3334/build/index-a8bdf364.js:695:13)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
at createElm (http://localhost:3334/build/index-a8bdf364.js:705:29)
import { JSXBase } from '@stencil/core/internal';
// render()
type SVG2Attributes = JSXBase.SVGAttributes & { href: string };
// @ts-ignore
const link = <use href="example" /> as SVG2Attributes;
return (
<svg>
{link}
</svg>
);