zoukankan      html  css  js  c++  java
  • 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="../js/vue.js"></script>
    </head>

    <body>
        <div id="app">
            {{a}}
        </div>
        <script>
            var vm = new Vue(
                {
                    el: "#app",
                    data: {
                        a: "hello vue"
                    },
                    // 对象初始化之后,数据观察(data observe)和事件配置(event watcher)之前调用
                    beforeCreate: function () {
                        console.log("beforeCreate");
                    },
                    // 在实例创建完成后被立即调用
                    created: function () {
                        console.log("created");
                    },
                    // 在挂载开始之前被调用,相关的渲染函数被调用
                    beforeMount: function () {
                        console.log("beforeMount");
                    },
                    // el被新创建的vm.$el替换,挂载成功
                    mounted: function () {
                        console.log("mouted");
                    },
                    // 数据更新时调用
                    beforeUpdate: function () {
                        console.log("beforeUpdate");
                    },
                    // 组件dom已经更新,组件更新完毕
                    updated: function () {
                        console.log("updated");
                    },
                   
                }
            
            );
            // 异步函数
            setTimeout(function() {
                        vm.a = "value changed";
                    }, 3000);
        </script>
    </body>

    </html>
  • 相关阅读:
    团队冲刺第九天
    团队冲刺第七天
    CSS 居中大全
    jquery 中fadeIn,fadeOut动画
    使用Fiddler提高前端工作效率 (实例篇)
    使用Fiddler提高前端工作效率 (介绍篇)
    python的一些学习资料(持续更新中)
    Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
    setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.原因和解决方案
    express cookie-session解惑
  • 原文地址:https://www.cnblogs.com/kukai/p/12378347.html
Copyright © 2011-2022 走看看