看代码class Background extends React.Component{ constructor(opts) { super(opts); this.initStatus();
}
initStatus() { this.state = { effect: false
}
}
render(){ this.initStatus(); return <div className={cs({background: true, effect: this.state.effect})}>
<div className="background-pannel">
<div className="background-image-back"></div>
</div>
<div className="background-pannel">
<div className="background-image"></div>
</div>
</div>
}
componentDidMount() { this.setState({effect: true}, ()=>{ console.log(this.state.effect);
})
}
}export { Background }为什么没有效果,打印出来的effect值依然是false?
添加回答
举报
0/150
提交
取消