vue生命週期

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue實例生命週期函數</title>
    <script src="./vue.js"></script>


</head>
<body>
<div id="app"></div>


<script>
    //生命週期函數就是vue實例在某一個時間點自動執行的函數
    var vm = new Vue({
        el:"#app",
        template:"<div>{{test}}</div>",
        data:{
            test:"hello world"
        },
        beforeCreate:function () {
            console.log("beforeCreate");
        },
        created:function(){
            console.log("Created");
        },
        beforeMount:function(){
            console.log(this.$el);
            console.log("beforemount");
        },
        mounted:function()
         {
            console.log("mounted");
         },
        beforeDestroy:function () {
            console.log("beforedestory");
        },
        destroyed:function () {
            console.log("destoryed");
        },
        beforeUpdate:function () {
            console.log("beforeUpdate");
        },
        updated:function () {
            console.log("updated");
        }


    })




</script>








</body>
</html>
發佈了30 篇原創文章 · 獲贊 1 · 訪問量 4294
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章