我认为标题是自我解释的,我在React组件中有一个按钮元素,我想点击它,它必须在5秒后弹出一个框
import React, { Component } from 'react';
import './Header.css';
class Header extends Component {
render() {
return (
<div>
<a class="waves-effect waves-light btn">This is the button !</a>
</div>
);
}
}
export default Header;
答案 0 :(得分:0)
我认为这应该有用
import React, { Component } from 'react';
import './Header.css';
class Header extends Component {
popupBox(){
setTimeout(()=> alert("hello"),5000)
}
render() {
return (
<div>
<a class="waves-effect waves-light btn" onClick={()=>this.popupBox()}> This is the button !</a>
</div>
);
}
}