Comments (7)
我们组件化是自己实现的,没有用小程序组件那一套,所以生命周期都可以自定义咯~
而页面的生命周期有依赖与小程序页面生命周期,componentDidMount
大致等价于小程序的 onReady
方法
from taro.
不过在小程序里面运行的时候,什么时机触发的componentDidMount呢?因为小程序没有类似的时机可用,怎么知道已经插入到真实的 DOM,或者已经从 DOM 卸载掉呢?
from taro.
@honchy 小程序页面有 onReady
方法的
from taro.
@luckyadam 具体到组件呢,比如自定义了一个 Button 组件,Button 组件会有这些生命周期方法吗?
from taro.
嗯嗯,有的,组件同样有生命周期~ 组件生命周期依赖于页面生命周期来实现~
from taro.
cool
from taro.
有个疑问是为什么把didshow放在didmount前执行?有个场景是当前业务只在挂载完成的时候执行一次,然后每次页面展示的时候执行另外的业务,场景应该不少见。(willmount非异步很绝望)即是
componentDidMount() {
// 只在第一次加载的时候执行
checkLogin()
}
componentDidShow() {
// 页面加载时候执行
runDependenceLogin()
}
from taro.
Related Issues (20)
- 抖音小程序应该如何正确使用事件? HOT 18
- @tarojs/plugin-platform-h5 无法正常编译 HOT 1
- 在开发模式中启动预构建未更新路由表导致页面加载失败
- 如何实现分包间的状态管理
- WXMLRT_$gwx:./base.wxml:template:27:20: Template `tmpl_0_23` not found. HOT 1
- input type='nickname' 昵称无法填入到input
- 在canvas上进行双指缩放操作e.touches返回的数组有时候不准确
- H5端 @tarojs/components 包 treeshaking 失效 HOT 1
- taro 3.6.10 版本 打包H5在 android 9手机报错白屏:"Uncaught SyntaxError: 'super' keyword unexpected here", source: https://***/js/9.01ab024a.js (2) HOT 4
- 在config dev.js文件中devServer的historyApiFallback进行配置不生效
- 开启半编译模式 —— CompileMode报错 HOT 1
- 【虚拟瀑布流组件】能否添加gap相关字段? HOT 4
- skyline渲染模式下,自定义tabbar真机不会显示
- text,label组件上的onLongPress不生效
- 微信小程序channel-live HOT 1
- 京东小程序无法处理http status code 20x?
- Taro 打包 支付宝小程序插件,找不到插件路径
- 希望增加react-native-windwos的支持
- v4 版本有什么功能 HOT 1
- 集成模式 如何支持 react native原生的app.json中的配置项 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from taro.