【taro react】----打包微信小程序后 onShow 多次执行(随着进入页面的次数在不断的累计)
2023-09-14 09:15:07 时间
页面子组件 onShow 执行多次【累计执行】
1. 出现问题的代码
test.jsx 测试组件代码
import React, { Component } from 'react'
import { View } from '@tarojs/components'
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
export default class RuiPoster extends Component {
constructor(props) {
super(props)
}
state = {
count: 0
}
$instance = getCurrentInstance();
componentDidMount(){
const onShowEventId = this.$instance.router.onShow;
eventCenter.on(onShowEventId, this.onShow);
}
onShow = () => {
console.log('进入页面第几次:',++this.state.count)
console.log('onshow', +new Date())
}
render () {
return (
<View>
</View>
)
}
}
2. 代码执行结果
相关文章
- Windows服务项目打包成安装包(Windows服务)-----------VS2017项目程序打包成.msi或者.exe
- Unity手游之路<十一>资源打包Assetbundle
- webpack打包内存溢出的解决方法
- webpack打包提取css到独立文件
- hbuilder打包APP
- 使用Cordova将您的前端JavaScript应用打包成手机原生应用
- 复制粘贴,快速将Python程序打包成exe
- pyinstaller利用spec文件打包的使用模板
- vue.js项目打包报错Error: You appear to be using a native ECMAScript module configuration file
- Eclipse集成Maven打包时报错:[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format
- 软件测试『持续集成』篇——自动编译和打包(中-1)
- DFS和动态规划——字符串匹配 真蛋疼 为*的情况需考虑匹配0个、1个、2个情况 DFS会超时 正则匹配的话 需要向前看x*的情况 打包处理
- Android Stdudio 打包Apk签名时出现状态窗口报错提示:Please select at least one of the signature versions to use
- 解决webpack打包错误问题
- Maven构建分布式项目时子模块相互依赖打包技巧