众所周知,vue2有生命周期,而vue3也有
而vue2的created和beforecreated在vue3中都由setup替代了<script setup lang="ts"> import { onBeforeMount, onMounted, onBeforeUpdate, onUpdated,onBeforeUnmount,onUnmounted } from 'vue' console.log('创建生命周期') onBeforeMount(() => { console.log('挂载前') }) onMounted(() => { console.log('挂载完毕') }) onBeforeUpdate(() => { console.log('更新前') }) onUpdated(() => { console.log('更新完毕') }) onBeforeUnmount(() => { console.log('卸载前') }) onUnmounted(() => { console.log('卸载完毕') }) </script> <template> <div> </div> </template> <style scoped></style>
标签:生命周期,console,log,onMounted,vue2,vue3,06 From: https://www.cnblogs.com/wencaiguagua/p/18070965