【发布时间】:2020-08-07 23:20:23
【问题描述】:
From the "Namespaces Crash Course" by Mozilla:“有时需要定义参数,以便它们可以在许多不同的元素上重复使用,并且仍然被认为是相同的参数,与使用它们的元素无关。”
给出的例子:
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script xlink:href="cool-script.js" type="text/ecmascript"/>
</svg>
谁能给我一个例子,说明你为什么要命名一个参数?我看到他们正在引用 xlink 命名空间,并且仅将 href 参数与 xlink 相关联。但这意味着元素本身的名称空间与参数不同。
另外,显然 SVG 2.0 是 deprecating the use of Xlink in favor of a plain ole href attribute。这意味着您可以从xlink:href 中删除xlink:。在 2.0 之前,您是否无法在没有它的情况下链接 SVG 元素?它是否像 mixin,您可以在其中将来自其他 xml 工具(“方言”)的新属性添加到元素中,有点像用类固醇或益智药注入元素以使其更好?
【问题讨论】:
标签: xml svg namespaces xlink