reactApplyAPILifecycle阶段componentWillUnmount本页总览componentWillUnmount2024年03月06日柏拉文越努力,越幸运 一、认识 componentWillUnmount 用于组件卸载前,清理一些注册是监听事件,或者取消订阅的网络请求等。一旦一个组件实例被卸载,其不会被再次挂载,而只可能是被重新创建。 二、语法 componentWillUnmount(){ clearTimeout(this.timer) /* 清除延时器 */ this.node.removeEventListener('click',this.handerClick) /* 卸载事件监听器 */}