• 首页
  • css3教程
  • html5教程
  • jQuery手册
  • vue手册
  • php手册
  • MySQL手册
  • apache手册
  • redis手册
  • beforeCreate

    • 类型:Function
    • 详细:在实例初始化之后,数据观测(data observer)和 event/watcher 事件配置之前被调用。
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="vue.js"></script>
    </head>
    <body>
        <div id="app" ref="app">
            {{ name }}
        </div>
    </body>
        <script>
            let vm=new Vue({
                el:"#app",
                data:{
                    name:"liuting",
                },
                beforeCreate(){
                    console.log("创建前:");
                    console.log(this.$el);
                    console.log(this.$data);
                },
                created(){
                    console.log("创建完成:");
                    console.log(this.$el);
                    console.log(this.$data);
                },
                beforeMount(){
                    console.log("挂载前:");
                    console.log(this.$el);
                    console.log(this.$data);
                },
                mounted(){
                    console.log("挂载完成:");
                    console.log(this.$el);
                    console.log(this.$data);
                },
                beforeUpdate(){
                    console.log('=即将更新渲染=');
                    let name = this.$refs.app.innerHTML;
                    console.log('name:'+name);
                },
                updated(){
                    console.log('==更新成功==');
                    let name = this.$refs.app.innerHTML;
                    console.log('name:'+name);
                },
                /*beforeDestory(){
                    console.log("销毁前:");
                },
                destoryed(){
                    console.log("销毁完成:");
                }*/
            });
        </script>
    </html>
    

    下篇:created