猿问

React数据获取为什么一定要在componentDidMount里面调用

React数据获取为什么一定要在componentDidMount里面调用


噜噜哒
浏览 664回答 3
3回答

眼眸繁星

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();}
随时随地看视频慕课网APP
我要回答