欢迎您 本站地址:
复制网址
手机查看
切换背景
源代码:
html编辑器
颜色值转换
点击运行
Vue 测试实例 - 小库网 <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/3.2.31/vue.global.min.js"></script> <div id="app"> <lifecycle-demo></lifecycle-demo> </div> <script> const LifecycleDemo = { template: `<div>{{ message }}</div>`, data() { return { message: 'Hello, Vue!' }; }, beforeCreate() { console.log('beforeCreate: 实例刚刚被创建'); }, created() { console.log('created: 实例创建完成'); }, beforeMount() { console.log('beforeMount: 挂载开始之前'); }, mounted() { console.log('mounted: 实例已挂载'); }, beforeUpdate() { console.log('beforeUpdate: 数据更新之前'); }, updated() { console.log('updated: 数据更新完成'); }, beforeUnmount() { console.log('beforeUnmount: 实例卸载之前'); }, unmounted() { console.log('unmounted: 实例已卸载'); } }; const app = Vue.createApp({ components: { LifecycleDemo } }); app.mount('#app'); </script>
运行结果:
小库提示
扫描下方二维码,访问手机版。
打赏
关闭