vue生命周期中常用的两个方法

<!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="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>   
    <div id="app">
        <son></son>
    </div>
    <template id="son">
        <div>
            <h2>子组件</h2>
        </div>
    </template>
    <script>
        new Vue({
            el: '#app',
            data: {

            },
            methods: {

            },
            components: {
                son: {
                    template:'#son',
                    data(){
                        return{

                        }
                    },
                    methods:{

                    }
                }
            },
            created(){
                debugger
                console.log("created~");

            },
            mounted(){
                debugger
                console.log("mounted~");
            }
        });
    </script>
</body>
</html>

 

 

 

 

 

posted @ 2021-02-04 12:40  小庄的blog  阅读(120)  评论(0编辑  收藏  举报