我目前正在使用Fluent UI 按钮。
我需要做的是根据disabled
标志在按钮的正常和禁用状态之间动态切换。我尝试执行以下操作:
import { PrimaryButton as FluentUIButton } from 'office-ui-fabric-react';
export class App extends React.Component {
disabled: boolean = false;
render() {
return (
<FluentUIButton text={"Click me!"} disabled={this.disabled} />
);
}
invert() {
setTimeout( () => {
this.disabled = !this.disabled;
this.invert();
}, 2000)
}
componentWillMount() {
this.invert();
}
}
但是,更改disabled
似乎没有效果,并且按钮对更改没有反应。
如何在更改时使按钮动态disabled
更改?