美文网首页
【Vue2】Vue 生命周期、complete 和 watch

【Vue2】Vue 生命周期、complete 和 watch

作者: 睡神疯子 | 来源:发表于2021-04-27 15:29 被阅读0次
    <template><div>{{apps}}</div></template>
    <script>
      export default {
        name:'',
        components: {},
        props:[''],
        data () {
          return {
            test: 0,
            app: 0
          };
        },
        beforeCreate() {
          console.log('beforeCreate')
          // this.app = 1
        },
        created() {
          console.log('created')
          this.test = 1
        },
        watch: {
          test() {
            console.log('watch')
          }
        },
        beforeMount() {
          console.log('beforeMount')
        },
        mounted() {
          console.log('mounted')
        },
        methods: {},
        computed: {
          apps() {
            console.log('computed')
            return this.app + 2;
          }
        }
      }
    </script>
    

    执行结果

    beforeCreate
    created
    beforeMount
    computed
    mounted
    watch

    相关文章

      网友评论

          本文标题:【Vue2】Vue 生命周期、complete 和 watch

          本文链接:https://www.haomeiwen.com/subject/vttprltx.html