zoukankan      html  css  js  c++  java
  • vue_实例_组件的生命周期

     

     重绘重排 中重复出现的是

    mounted(){...}

    beforeUpdate(){...}

    uptated(){...}

    其他钩子函数只会出现一次

    • <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title>viewModel 的生命周期</title>
          <link rel="stylesheet" type="text/css" href="./css/index.css">
      </head>
      <body>
          <div id="test">
              <button type="button" @click="destroyVue">卸载 viewModel</button>
              <p v-show="isShow">生当作人杰,死亦为鬼雄。</p>
          </div>
          <script src="./js/vue.js"></script>
          <script>
              new Vue({
                  el: "#test",
                  data:{
                      isShow: true
                  },
                  methods:{
                      destroyVue(){
                          this.$destroy();
                      }
                  },
                  mounted(){    // 初始显示之后立即执行: 执行异步任务
                 this.timerId = window.setInterval(()=>{
                     console.log("27 ---- mounted");
                     this.isShow = !this.isShow
                 }, 1000)
             },
             beforeDestroy(){
                 console.log("32 ---- beforeDestroy");
                 window.clearInterval(this.timerId)
             },
             /****************************************************************************/
                  beforeCreate(){
                      console.log("36      beforeCreate")
                  },
                  created(){
                      console.log("40      createdcreated")
                  },
                  beforeMount(){
                      console.log("42      beforeMount")
                  },
                  beforeUpdate(){
                      console.log("46      beforeUpdate")
                  },
                  updated(){
                      console.log("49      updated")
                  },
                  destroyed(){
                      console.log("52      destoryed")
                  }
              })
          </script>
      </body>
      </html>
    --------小尾巴 ________一个人欣赏-最后一朵颜色的消逝-忠诚于我的是·一颗叫做野的心.决不受人奴役.怒火中生的那一刻·终将结束...
  • 相关阅读:
    RvmTranslator7.3.2
    PipeCAD
    Open CASCADE Technology 7.5.0 released
    IsoAlgo 环路处理
    OD流向地图的绘制——利用ArcGIS与Gephi方法
    Python调用百度地图和高德地图API批量获取国内城市地址经纬度坐标
    ArcGIS地理数据库Geodatabase
    Gephi 安装与简明教程
    安装Java SDK
    ArcGIS中自定义脚本工具制作
  • 原文地址:https://www.cnblogs.com/tianxiaxuange/p/10385364.html
Copyright © 2011-2022 走看看