您当前的位置: 首页 > 

小志的博客

暂无认证

  • 1浏览

    0关注

    1217博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Vue——生命周期1

小志的博客 发布时间:2019-09-02 22:46:54 ,浏览量:1

参考:vue官网 1、代码如下:




  
  Vue_生命周期1





    销毁
    hello world




  new Vue({
      el:'#test',
      data:{
          isShow:true
      },
      mounted(){/*初始化显示后立即调用(调用1次)*/
          this.intervalId=setInterval(()=> {
              console.log("-----------")
              this.isShow =!this.isShow
          },1000)
      },
      beforeDestroy(){/*死亡之前调用(调用1次)*/
          /*清楚定时器*/
          clearInterval(this.intervalId)
      },
      methods:{/*销毁方法*/
          destroy(){
              this.$destroy()
          }
      }
  })





2、效果图如下: 在这里插入图片描述

关注
打赏
1661269038
查看更多评论
立即登录/注册

微信扫码登录

0.0472s