首页 > 其他 > 详细

vue基础---10生命周期

时间:2021-09-12 12:46:07      阅读:38      评论:0      收藏:0      [点我收藏+]

00.生命周期

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h1>{{message}}</h1>
        <h1 :class="className">hello</h1>
    </div>
    <script type="text/javascript">
        var app=new Vue({
            el:"#app",
            data:{
                message:"hello vue",
                className:"active"
            },
            beforeCreate(){//创造前
                // 数据data和方法methods还未绑定到应用对象app上
                console.log(beforCreate);
            },
            created(){//创造
                // 数据data和方法methods绑定到应用对象app上
                console.log(created);                
            },
            beforeMount(){//渲染前
                //根据数据生成的DOM对象是获取不到的
                console.log(beforeMount);
            },
            mounted(){//渲染
                console.log(mountd);
            },
            methods:{
                clickEvent:function(){    
            }
            },
            beforeUpdate() {
                //数据更改,但内容未更改之前
                console.log(beforeUpdate)
            },
            updated() {
                //内容已更新完毕
                console.log(update)
            },
            beforeDestroy() {
                //应用销毁之前
                console.log("beforeDestory")
            },
            destroyed(){
                //应用销毁之后
                console.log("Destory")
            }        
        })
    </script>
</body>
</html>

 

vue基础---10生命周期

原文:https://www.cnblogs.com/hunter1/p/15250823.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!