给 a 标签添加一个事件
阻止默认事件
e.preventDefault();
class view extends Component {onAtag(e) {// 阻止默认事件 放置跳转e.preventDefault();console.log("烦烦烦滚滚");}render() {return (<div><ahref='true'onClick={(e) => {this.onAtag(e);}}></a></div>);}}
阻止冒泡
e.stopPropagation();
class view extends Component {onDiv() {console.log("div");}onDivAtag(e) {e.preventDefault();// 阻止事件冒泡e.stopPropagation();console.log("div_aaaaaa");}render() {return (<div><divonClick={() => {this.onDiv();}}><ahref='true'onClick={(e) => {this.onDivAtag(e);}}></a></div></div>);}}