本文介绍了select()和selectAll()之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select()和selectAll()有什么区别?

What is the difference between select() and selectAll()?

为什么第二个不附加ap标签?

Why doesn't the second one append a p tag?

divSelection = d3.select('#div-vis').selectAll('p').data(['dummy']).enter().append('p');

divSelection = d3.select('#div-vis').select('p').data(['dummy']).enter().append('p');


推荐答案

来自:

当你说 d3.select(#vis),选择的父节点仍然是文档元素。然后,当您说 selectAll(p)时,将父节点定义为先前选择的#vis元素,因为selectAll是嵌套运算符。这只发生在selectAll而不是select。

When you say d3.select("#vis"), the parent node of the selection is still the document element. When you then say selectAll("p"), you define the parent node as the previously-selected #vis element, because selectAll is a nesting operator. That only happens with selectAll and not select.

这篇关于select()和selectAll()之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 13:32