组件的生命周期学习笔记

[复制链接]
查看: 321   回复: 0     小程序

303

主题

303

帖子

1686

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1686
2024-7-14 09:22:01   显示全部楼层   阅读模式  
组件的生命周期_00000.jpg


微信开发文档地址:https://developers.weixin.qq.com ... figuration/app.html

教学地址

调用
<view>
  <c2 wx:if="{{c2Show}}"></c2>
  <button type="primary" bind:tap="deadC" >销毁自定义组件</button>
</view>
  deadC() {
    console.log("销毁测试");
    this.setData({
      c2Show:!this.data.c2Show
    })
  },

组件
lifetimes:{
  created(){
    console.log('创建');
  },
  attached(){
    console.log('挂载');
  },
  detached(){
    console.log('销毁');
  }
}

lifetimes 下面三种状态 created attached detated  创建挂载销毁
回复

使用道具 举报

您需要登录后才可以回帖   登录 立即注册

高级模式

南通谢凡软件科技有限公司