React數(shù)據(jù)獲取為什么一定要在componentDidMount里面調(diào)用
3 回答

眼眸繁星
TA貢獻(xiàn)1873條經(jīng)驗(yàn) 獲得超9個(gè)贊
import React, { Component } from 'react';
class MyCompnent extends Component {
constructor(props) {
super(props);
this.state = {isHover: false};
this.onMouseEnter = this.onMouseEnter.bind(this);
}
componentDidMount() {
$("#aaa").on('hover', ()=> {
$(this).addClass('myHover');
});
}
onMouseEnter() {
this.setState({isHover : true});
}
render() {
const { isHover } = this.state;
return(
);
}
- 3 回答
- 0 關(guān)注
- 712 瀏覽
添加回答
舉報(bào)
0/150
提交
取消