gpt4 book ai didi

未定义图像上 href 的 SVG 命名空间前缀 xlink

转载 作者:行者123 更新时间:2023-12-03 14:56:00 24 4
gpt4 key购买 nike

我有一个 svg 内容,看起来有点像这样:

<svg height="1000" preserveaspectratio="xMidYMid meet" style="width: 100%; height: 100%; transform: translate3d(0px, 0px, 0px);" viewbox="0 0 1000 1000" width="1000"
xmlns="http://www.w3.org/2000/svg">
<defs>
<clippath id="__lottie_element_2">
<rect height="1000" width="1000" x="0" y="0"></rect>
</clippath>
<clippath id="__lottie_element_4">
<path d="M0,0 L3048,0 L3048,2431 L0,2431z"></path>
</clippath>
</defs>
<g clip-path="url(#__lottie_element_2)">
<g clip-path="url(#__lottie_element_4)" opacity="1" style="display: block;" transform="matrix(0.5006899833679199,0,0,0.5006899833679199,-263.051513671875,-180.58868408203125)">
<g class="H01 2k" opacity="1" style="display: block;" transform="matrix(0.9999813437461853,0.006108480971306562,-0.006108480971306562,0.9999813437461853,504.42333984375,488.25836181640625)">
<image height="1442px" preserveaspectratio="xMidYMid slice" width="2048px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACAA...MC2S3oHLwAAAABJRU5ErkJggg=="></image>
</g>
<g opacity="1" style="display: block;" transform="matrix(0.9947565197944641,-0.10227109491825104,0.10227109491825104,0.9947565197944641,452.203369140625,619.6126708984375)">
<image height="1442px" preserveaspectratio="xMidYMid slice" width="2048px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACAAA...BJRU5ErkJggg=="></image>
</g>
<g opacity="1" style="display: block;" transform="matrix(0.9999813437461853,0.006108480971306562,-0.006108480971306562,0.9999813437461853,504.40704345703125,490.92486572265625)">
<image height="1442px" preserveaspectratio="xMidYMid slice" width="2048px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACAAAAAWiCAYA...3+XcSAElFTkSuQmCC"></image>
</g>
<g opacity="1" style="display: block;" transform="matrix(0.9999813437461853,0.006108480971306562,-0.006108480971306562,0.9999813437461853,504.42333984375,488.25836181640625)">
<image height="1442px" preserveaspectratio="xMidYMid slice" width="2048px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACAAAAAWiCA...AAASUVORK5CYII="></image>
</g>
</g>
</g>
</svg>

Here是原始文件。

但是每当我尝试通过浏览器显示它时,我都会收到此错误:
This page contains the following errors:
error on line 1 at column 982067: Namespace prefix xlink for href on image is not defined
Below is a rendering of the page up to the first error.

我不知道为什么。请问怎么了?

最佳答案

<svg>元素缺少 xlink 的声明命名空间,尽管它在 <image> 中使用元素。所以只需添加如下:

<svg height="1000" preserveaspectratio="xMidYMid meet" style="width: 100%; height: 100%; transform: translate3d(0px, 0px, 0px);" viewbox="0 0 1000 1000" width="1000"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

SVG2 deprecated the xlink namespace for href attributes. .所以以后,改 xlink:href="..."href="..."将是更好的解决方案。

关于未定义图像上 href 的 SVG 命名空间前缀 xlink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59138117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com