vue教程2-01 vue生命周期、钩子函数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    </style>
    <script src="vue.js"></script>
</head>
<body>
    <div >
        {{msg}}
    </div>
    <script>
        var vm=new Vue({
            el:'#box',
            data:{
                msg:'well'
            },
            created:function(){
                alert('实例已经创建');
            },
            beforeCompile:function(){
                alert('编译之前');
            },
            compiled:function(){
                alert('编译之后');
            },
            ready:function(){
                alert('插入到文档中');
            },
            beforeDestroy:function(){
                alert('销毁之前');
            },
            destroyed:function(){
                alert('销毁之后');
            }
        });

        /*点击页面销毁vue对象*/
        document.onclick=function(){
            vm.$destroy();
        };
    </script>
</body>
</html>

 网上找来一张流程图:

vue教程2-01 vue生命周期、钩子函数

相关文章:

  • 2021-10-23
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-20
  • 2021-10-06
  • 2021-10-08
  • 2021-12-08
相关资源
相似解决方案