zoukankan      html  css  js  c++  java
  • Vue.js(4)- 生命周期

    当new的时候,就创建了一个vue实例,这个实例就是vue框架的入口,也是VM层

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <script src="./vue-2.5.16.js"></script>
    </head>
    
    <body>
      <div id="app">
        <input type="text" v-model="message">
        <h2>{{message}}</h2>
      </div>
      <script>
        var vm = new Vue({
          el: "#app",
          data: {
            message: 'my words'
          },
          beforeCreate() {
            console.group("beforeCreate");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          created() {
            console.group("created");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          beforeMount() {
            console.group("beforeMount");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          mounted() {
            console.group("mounted");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          beforeUpdate() {
            console.group("beforeUpdate");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          updated() {
            console.group("updated");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          beforeDestroy() {
            console.group("beforeDestroy");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
          destroyed() {
            console.group("destroyed");
            console.log("%c%s", "color:red", "el     : " + this.$el); 
            console.log("%c%s", "color:red", "data   : " + this.$data);  
            console.log("%c%s", "color:red", "message: " + this.message)
          },
        })
      </script>
    </body>
    
    </html>

  • 相关阅读:
    插槽分发内容
    Java学习-sgg-day07-20200422-复习
    Java学习-sgg-day06-20200421-今天晚上在下载资料
    Java学习-sgg-day05-20200420
    Java学习之面向对象之总结-sgg-day04-20200419
    Java学习之Eclipse的使用-sgg-day04-20200419
    Java学习之面向对象-sgg-day04-20200419
    Java学习之面向对象-sgg-day03-20200418
    Java学习总结-前三天
    Java学习之-sgg-day03-20200418
  • 原文地址:https://www.cnblogs.com/houfee/p/9923028.html
Copyright © 2011-2022 走看看