Vue笔记

生命周期

  beforeCreate:

    vue实例初始化后执行

    数据被观察前

  created:

    在data observation, computed properties, methods, watch/event callbacks. 之后

  beforeMount:

    ~

  mounted:

    不保证所有的组件都被挂载完毕,如果要保证所有组件挂载完毕,使用 vm.$nextTick 

mounted() {
  this.$nextTick(function () {
    // Code that will run only after the
    // entire view has been rendered
  })
}

 

  beforeUpdate:

    

 

 

 

watch中 

  deep作用

    数组或者对象改变值之后,vue是不知道的,所以需要 将deep设置为 true,方能监测到。

  immediate:

    页面首次加载立即执行

 watch: {
    colours: {
      // This will let Vue know to look inside the array
      deep: true,

      // We have to move our method to a handler field
      handler()
        console.log('The list of colours has changed!');
      }
    }
  }

 

posted @ 2021-09-27 21:34  超难微猫  阅读(23)  评论(0编辑  收藏  举报