微信开发文档地址: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  创建挂载销毁 
 |