gpt4 book ai didi

javascript - D3.js - "svg:"中的 "svg:rect"是必须的吗?

转载 作者:行者123 更新时间:2023-11-29 18:13:02 24 4
gpt4 key购买 nike

例如:

svg.append("svg:rect");
  1. 如果我删除“svg:”怎么办?它似乎没有“svg:”也能工作。丢弃它有什么潜在的问题吗?
  2. “svg:”是 d3 特有的东西还是在 svg 时通常需要使用元素?

最佳答案

来自 d3.js append() documentation

The name may be specified either as a constant string or as a function that returns the DOM element to append. When the name is specified as a string, it may have a namespace prefix of the form "namespace:tag". For example, "svg:text" will create a "text" element in the SVG namespace. By default, D3 supports svg, xhtml, xlink, xml and xmlns namespaces. Additional namespaces can be registered by adding to d3.ns.prefix. If no namespace is specified, then the namespace will be inherited from the enclosing element; or, if the name is one of the known prefixes, the corresponding namespace will be used (for example, "svg" implies "svg:svg").

因此命名空间(在大多数情况下)是可选的,因为 this提交。

关于javascript - D3.js - "svg:"中的 "svg:rect"是必须的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25620989/

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