我想在保持屏幕的同时管道程序的标准输出.
通过一个简单的例子(echo
这里使用仅用于说明目的):
$ echo 'ee' | foo
ee
< - 我希望看到的输出
我知道tee可以将stdout复制到文件中,但这不是我想要的.
$ echo 'ee' | tee output.txt | foo
我试过
$ echo 'ee' | tee /dev/stdout | foo
但是因为tee输出到了/dev/stdout
管道,所以它不起作用foo
我正在使用标签渲染SVG组件.这些标签组件需要根据其文本内容(以及它们的大小)正确布局,以避免重叠.
为了获得每个标签的实际大小,每次更新标签内容时都需要双重渲染.
在标签组件级别,我需要
然后,在每次重绘时:
到目前为止,这是我如何实现我的标签组件:
var Label = React.createClass({
updateBBox: function() {
// Trigger re-rendering
this.setState({
bbox: this.getDOMNode().getBBox()
});
},
componentDidMount: function() {
// Will trigger a re-rendering at mount
this.updateBBox();
},
componentDidUpdate: function(prevProps, prevState) {
// If content has changed, re-render
if (this.props.content !== prevProps.content) {
this.updateBBox();
}
},
render: function() {
// Render according to size from current bounding box if any cached
// ... …
Run Code Online (Sandbox Code Playgroud) 我需要设置样式(仅限CSS)最后一个子元素,同时排除具有特定类的元素.
例如,我想要风格
<ul>
<li>Bar</li>
<li>Bar</li>
<li>Bar</li>
<li>Should have a green background</li>
<li class='foo'>Bar</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
没有类'foo'的最后一个li应该是绿色的.我试过了
li:not(.foo):last-child {
background-color: green;
}?
Run Code Online (Sandbox Code Playgroud)
要么
li:not(.foo):last-of-type {
background-color: green;
}?
Run Code Online (Sandbox Code Playgroud)
但它不起作用.