var Vote = React.createClass({
onVote(event){
console.log("event triggered");
event.stopPropagation();
event.nativeEvent.stopImmediatePropagation();
},
render: function() {
return <div>
<ul>
<li onClick={this.onVote}>
<input
type="radio"
name="vote_for_president"
value="donald"
onChange={this.onVote}/>
Donald
</li>
<li onClick={this.onVote}>
<input type="radio"
name="vote_for_president"
value="clinton"
onChange={this.onVote}
/>Clinton
</li>
</ul>
</div>;
}
});
Run Code Online (Sandbox Code Playgroud)
我需要在单击列表项和更改单选按钮时触发一个事件,并执行相同的操作。这里的问题是当我单击无线电输入并且事件传播到列表项的单击事件时,事件被调用两次。停止传播和本机停止方法不起作用。
这里的目的是我希望整个 li 行都是可点击的,并且在单击单选按钮时不应两次调用事件。
这是 jsfiddle https://jsfiddle.net/dbd5f862/
我开始学习C编程.我经历了这个例子
#include <stdio.h>
main() {
printf("Hello, World");
}
Run Code Online (Sandbox Code Playgroud)
据说主要是该计划的开始.那么,如果main首先启动,第一行何时以及如何执行?