小程序page&component生命周期

Page

在这里插入图片描述

component

Component({
    
    
  lifetimes: {
    
    
    attached: function() {
    
    
      // 在组件实例进入页面节点树时执行
    },
    detached: function() {
    
    
      // 在组件实例被从页面节点树移除时执行
    },
  },
  // 以下是旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
  attached: function() {
    
    
    // 在组件实例进入页面节点树时执行
  },
  detached: function() {
    
    
    // 在组件实例被从页面节点树移除时执行
  },
  // ...
})

猜你喜欢

转载自blog.csdn.net/weixin_43865875/article/details/123598552