欢迎来到沐沐的博客

摘要: 注意:只有类组件才有生命周期钩子函数,函数组件没有生命周期钩子函数。 生命周期 装载阶段:constructor() render() componentDidMount() 更新阶段:render() componentDidupDate() 卸载阶段:componentWillUnmount() 阅读全文
posted @ 2022-08-13 13:50 前端小二&沐沐 阅读(1112) 评论(0) 推荐(0)
摘要: 如何定义state 在类组件 中,在constructor()中使用this.state={}来定义 class A extends Component { constructor (props) { super(props) // 调用Component的构造函数 // 定义state this. 阅读全文
posted @ 2022-08-13 10:46 前端小二&沐沐 阅读(213) 评论(0) 推荐(0)