此时,元素svg上不允许使用属性data-ls.如何纠正它 [英] Attribute data-ls not allowed on element svg at this point. how to rectify it

查看:349
本文介绍了此时,元素svg上不允许使用属性data-ls.如何纠正它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用w3cvalidator检查我的网站时

While checking my site with w3cvalidator

它显示了此错误此时不允许在svg元素上使用属性data-ls ,并且 svg结束标记与当前打开的元素(使用)的名称不匹配.

it shows the this error Attribute data-ls not allowed on svg element at this point and End tag svg did not match the name of the current open element (use).

这是我使用的示例代码.

here is a sample code i used.

<svg class="ls-l" style="top:320px;left:30%;white-space: nowrap;" 
    data-ls="offsetxin:-15; offsetyin:10; delayin:6854; offsetxout:-15; offsetyout:10; durationout:500; showuntil:1000; easingout:easeInOutQuart; scalexin:0; scaleyin:0; scalexout:0; scaleyout:0;" 
    width="50" height="50" viewBox="0 0 64 64" >
    <use xlink:href="#location-pin">
</svg>

谢谢....

推荐答案

数据属性对于svg并非严格有效,您可以使用getAttribute和setAttribute但可以使用html

data- attributes are not strictly valid for svg you can get and set them using getAttribute and setAttribute but the html data attribute API is not available, hence the warning.

通常的XML方式是声明一个自定义名称空间,然后在该名称空间中具有属性,例如具有xmlns:ls="<something appropriate for you>"ls:<something>="offsetxin...",然后使用getAttributeNS

The usual XML way would be to declare a custom namespace and then have the attribute in that namespace e.g. have a xmlns:ls="<something appropriate for you>" and ls:<something>="offsetxin..." and then access the data using getAttributeNS

<use>问题是您没有关闭<use>标记.您需要将其写为<use/><use></use>

The <use> issue is that you don't close the <use> tag. You either need to write it as <use/> or <use></use>

这篇关于此时,元素svg上不允许使用属性data-ls.如何纠正它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆