草庐IT

Children

全部标签

javascript - d3.tree => 转换似乎不起作用

我使用d3js创建了一个树形布局图。节点可单击以切换显示子项。应该将子节点插入到预定义的位置,然后过渡到所需的位置。问题是插入坐标总是关闭的。使用Firebug进行调试时,它显示在添加新节点后,其坐标直接为x=51.42857142857142和y=200.0,即使行.attr("transform","translate(90,100)")应该改变它们(我在这里使用固定值,以进一步确定问题。我的错误在哪里?完整代码://Togglechildren.functiontoggle(d){if(d.children){d._children=d.children;d.children=n

javascript - 在 react 中将值传递给子组件(this.props.children)

我在布局中有一个子组件,我也想传递一个Prop值。但我不知道怎么办。在下面的类中,layoutFileDataRequest()在单击事件时从子组件接收字符串变量。需要将该值发送到this.props.children组件之一,以便它可以更新。我该怎么做?在下面的代码中React.cloneElement(child,{不会改变它总是保持不变,这意味着我无法更新child属性。exportdefaultclassLayoutextendsReact.Component{constructor(props){super(props)this.layoutFileDataRequest=t

javascript - 在 promise 中使用 setState 后,React 不会重新呈现

每次更改props时,组件都会调用onTermChange并获取此组件的详细信息,并promise返回一个对象数组。问题是当调用setState时,什么也没有发生,组件也没有重新渲染新的细节。module.exports=React.createClass({displayName:'TaxonomySelect',getInitialState:function(){return{children:undefined};},componentDidMount:function(){this.onTermChange(this.props.term);},componentWillRe

javascript - react : Use this. props.children 或将组件作为命名 Prop 传递

我正在构建一个需要渲染一些子组件的组件。更具体地说,我有一个map组件,我希望在其上显示一个图例组件。constMap=props=>({this.props.children});//Usage:constMapWithLegend=()=>();//Usage:constMapWithoutLegend=()=>();然而,这也可以用命名Prop来表达:constMap=({legend}=>({legend});//Usage:constMapWithLegend=()=>();//Usage:constMapWithoutLegend=()=>();我不确定哪种方式在扩展性和可

javascript - 在 javascript 中实现方形 TreeMap

我目前正在尝试用Javascript实现TreeMap算法。更具体地说,算法在SquarifiedTreemaps中描述。.给出的伪代码如下所示:proceduresquarify(listofrealchildren,listofrealrow,realw)beginrealc=head(children);ifworst(row,w)但是我的JavaScript看起来像:varc=children[0];if(worst(row,w)>=worst(row.concat(c),w)){this.squarify(children.splice(1),row.concat(c),w)

javascript - 是否可以在不渲染的情况下深度遍历 React Children?

有没有办法获取所有的bar中的属性在“静态”下方,例如没有渲染?importReactfrom'react';importReactDOMfrom'react-dom';classFooextendsReact.Component{render(){return(//wanttocollectthis'bar'//wanttocollectthis'bar';);}}classFooTupleextendsReact.Component{render(){return(;);}}classWrapperextendsReact.Component{render(){React.Chil

javascript - 如何在对象内部执行递归归约函数?

我正在使用Javascript在客户端上执行此操作。我要转型:[{"id":10,"name":"Designer","slug":"designer","children":[{"id":11,"name":"UI/VisualDesigner","slug":"ui-visual-designer","children":[]},...]},{"id":1,"name":"SoftwareEngineer","slug":"software-engineer","children":[{"id":2,"name":"Back-EndDeveloper","slug":"back-e

Javascript "for of"在 IE 11 中失败

我有以下代码来选择和删除d3.js节点。if(d.children){for(varchildofd.children){if(child==node){d.children=_.without(d.children,child);update(root);break;}}}这在Chrome和Edge中运行良好,但在IE-11中因缺少;而失败。使用'of'循环似乎是一个问题。以前有没有其他人在IE中遇到过这个问题?如果遇到过,您是如何解决的? 最佳答案 这是ES2015(也称为ES6)功能,仅在现代浏览器中受支持。通常,您只会将此构

javascript - 如何仅处理子元素的委托(delegate)事件?

当使用.on委托(delegate)事件时,我如何定位子元素:我试过:childSelector=>*>:nth-child(n)但是当我从>开始时没有选择任何东西。$(selector).on(event,childSelector,handler);有时我想针对直接child,有时我不想:(伪代码)varfunc=function(selector,subSelector){$(selector).on("click",subSelector,function(){alert("mysubSelectorisclicked");});}func("#wrapper","direct

javascript - $ ('.className > button' ) 和 $ ('.className' ).children ('button' ) 有区别吗?

在jQuery中有什么区别$('.className>button')和$('.className').children('button')或者这些只是获得相同结果的替代语法? 最佳答案 不是说你最终会得到什么,但第一个可以完全卸载到浏览器的内置CSS选择引擎,而第二个需要jQuery做更多的工作并涉及更多的对象创建和清理。除非你在一个mousemove处理程序中使用很多元素来做这件事,否则这不太重要,即使那样...... 关于javascript-$('.className>butto