首页 > 其他分享 >036.Vue3入门,组件的生命周期

036.Vue3入门,组件的生命周期

时间:2024-08-11 20:05:33浏览次数:12  
标签:updated 生命周期 console log beforeDestroy Vue3 036 beforeCreate

1、App.vue代码如下:

<template>
  <div>
    <h3>主页面</h3>
    <button @click="change">改变</button>
  </div>
</template>

<script>
export default {
  beforeCreate() { console.log('beforeCreate') },
  created() { console.log('created') },
  beforeMount() { console.log('beforeMount') },
  beforeUpdate() { console.log('beforeUpdate') },
  beforeDestroy() { console.log('beforeDestroy') },
  mounted() { console.log('mounted') },
  updated() { console.log('updated') },
  destroyed() { console.log('destroyed') },
  methods: { change() { console.log('change') }
  }
}
</script>

2、效果如下:

 

标签:updated,生命周期,console,log,beforeDestroy,Vue3,036,beforeCreate
From: https://www.cnblogs.com/tianpan2019/p/18353825

相关文章