vue3 生命周期06
众所周知,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>
代码改变了我们,也改变了世界