简易列举vue3的生命周期函数
<script setup>
import { ref } from 'vue'
import { onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onBeforeUnmount, onUnmounted } from 'vue';
console.log('setup');
onBeforeMount(() => {
console.log('创建之前 ===> onBeforeMount');
})
onMounted(() => {
console.log('创建完成,===》 onMounted ===》已经可以操作dom元素了');
})
onBeforeUpdate(() => {
console.log('更新之前 ===》 onBeforeUpdate');
})
onUpdated(() => {
console.log('更新完成,===》 onUpdated');
})
onBeforeUnmount(() => {
console.log('卸载之前 ===》 onBeforeUnmount');
})
onUnmounted(() => {
console.log('卸载完成 ===》onUnmounted');
})
</script>
<style lang="scss" scoped>
</style>