前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >cssjshtml vue.js vue生命周期

cssjshtml vue.js vue生命周期

作者头像
葫芦
发布2019-04-17 15:21:25
5690
发布2019-04-17 15:21:25
举报
文章被收录于专栏:葫芦葫芦

Header.vue

代码语言:javascript
复制
<template>
  <header v-on:click="changetitle">
    <h1>{{title}}{{title1}}</h1>
  </header>
</template>

<script>
  export default {
    name: 'app-header',
    props: {
      title1: {
        type: String
      }
    },
    data() {
      return {
        title: 'Vue.js Demo'
      }
    },
    methods: {
      changetitle: function () {
        // this.title1 = 'changed';
        this.$emit("titleChanged","子to父组件传值");
      }
    },
    beforeCreate:function () {
      alert("beforeCreate,组件实例化之前执行的函数");
    },
    created:function () {
      alert("created,组件实例化完毕,但页面还未显示");
    },
    beforeMount:function () {
      alert("beforeMount,组件挂载前,页面仍未显示,但虚拟dom已经配置");
    },
    mounted:function () {
      alert("mounted,组件挂载后,此方法执行后,页面显示");
    },
    beforeUpdate:function () {
      alert("beforeUpdate,组件更新前,页面仍未更新,单虚拟dom已经配置");
    },
    updated:function () {
      alert("updated,组件更新,此方法执行后,页面显示")
    },
    beforeDestroy:function () {
      alert("beforeDestroy,组件销毁前");
    },
    destroyed:function () {
      alert("destroyed,组件销毁");
    }


  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  header {
    background: lightgreen;
    padding: 10px;
  }

  h1 {
    color: #222;
    text-align: center;
  }
</style>

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019/01/08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Header.vue
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档