这就是我目前使用两个输入框处理场景的方式.作为每个人的单独更新方法.可以/应该用一种handleChange方法来完成吗?
https://codepen.io/r11na/pen/bZKOpj?editors=0011
class App extends React.Component {
constructor(props) {
super(props);
this.handleChange1 = this.handleChange1.bind(this);
this.handleChange2 = this.handleChange2.bind(this);
this.state = {
name1: '',
name2: ''
};
};
handleChange1(e) {
this.setState({
name1: e.target.value
});
};
handleChange2(e) {
this.setState({
name2: e.target.value
});
};
render() {
return (
<div class="row column">
<Label name={this.state.name1}/>
<Input onChange={this.handleChange1} />
<Label name={this.state.name2}/>
<Input onChange={this.handleChange2} />
</div>
);
};
}
const Label = props => (
<p {...props}>Hello: <span className="label-name">{props.name}</span></p>
);
const Input = props => (
<input …Run Code Online (Sandbox Code Playgroud) 我有一个问题,测试使用window.DOMParser一些javascript
const stripLink = (url) => {
const parser = new DOMParser()
const link = parser.parseFromString(unescape(url),
'text/html').querySelector('a')
return link ? link.getAttribute('href') : url
}
Run Code Online (Sandbox Code Playgroud)
在摩卡咖啡中测试时会发出警告。
node:22883) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: DOMParser is not defined
Run Code Online (Sandbox Code Playgroud)
我猜这是因为在节点没有的DOMParser。我该如何解决?我尝试过各种事情,例如
var DOMParser = require('xmldom').DOMParser
sinon.stub(window, 'DOMParser', DOMParser)
Run Code Online (Sandbox Code Playgroud)
想,如果我有XMLDOM解析器它应该工作测试替代window.DOMParser,但事实并非如此。
任何想法如何得到这个工作?
你如何让iPython使用乳胶输出结果?
例如,在此页面上:http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/master/examples/notebooks/SymPy%20Examples.ipynb
如果我执行代码:
Rational(3,2)*pi + exp(I*x) / (x**2 + y)
Run Code Online (Sandbox Code Playgroud)
我得到输出:
Out[13]: 3*pi/2 + exp(I*x)/(x**2 + y)
Run Code Online (Sandbox Code Playgroud)
我想看看乳胶中的输出,如上面的链接所示.
使用rubular http://rubular.com/我试图从格式中解析小时分钟和秒4H40M20S
到目前为止,我有这个
(\d*)H(\d*)M(\d*)S
Run Code Online (Sandbox Code Playgroud)
哪个适用4H40M20S但不适用40M20S
在这种情况下,我需要更改以使其工作?