zoukankan      html  css  js  c++  java
  • Vue02 -- 生命周期

    <!DOCTYPE html>
    <html>
    <head>
        <title>Vue --- 生命周期</title>
    
    </head>
    
    <body>
        <div id="app">
            <input type="text" name="" v-model="a" placeholder="你的名字">
            <h1>你好!{{a}}</h1>
        </div>
    
        <div id="opp">
            {{date}}
        </div>
    
        <div id="hpp">
            <span v-html='link'></span>
        </div>
        
        <!-- <span v-pre>{{这里的内容不显示出来}}</span> -->
        
        <script type="text/javascript" src="https://unpkg.com/vue/dist/vue.min.js"></script>
        <script type="text/javascript">
    
            var app = new Vue({
                el:'#app',
                data:{
                    a:2
                },
                created:function () {
                    // Vue实例创建完成后调用,完成了数据的观测,但尚未挂在el。在初始化数据的时候使用
                    console.log(this.a)
                },
                mounted:function () {
                    // el挂载到实例后调用,一般第一个逻辑在这里写
                    console.log(this.$el)
                }
                // beforeDestroy实例销毁之前调用。主要解绑一些使用addEventListenter监听的事件等。
            })
    
            var opp = new Vue({
                el:'#opp',
                data:{
                    date:new Date()
                },
                mounted:function () {
                    var _this = this
                    this.timer = setInterval(function () {
                        _this.date = new Date(); // 修改date数据
                        console.log(_this.date)
                    },1000);
                },
                beforeDestroy:function () {
                    if (this.timer){
                        // Vue实例销毁前清除定时器
                        clearInterval(this.timer);
                    }
                }
            })
    
            var hpp = new Vue({
                el:'#hpp',
                data:{
                    link:'<a href="https://unpkg.com"> 输出html </a>'
                }
            })
    
    
        </script>
    </body>
    </html>
  • 相关阅读:
    unity 凸多形顶点排序
    unity Plane
    Git MAC电脑Git使用
    Spine运行库指南
    VsCode TypeScritp整理Import
    TypeScript 扩展声明文件 .d.ts
    UnityEditor 编辑多个场景里的对象,Revert 预制件实例
    unity 球形插值
    研究生基础咨询
    ACSM-CPT 考试资料
  • 原文地址:https://www.cnblogs.com/lee-xingxing/p/11103764.html
Copyright © 2011-2022 走看看