3.1 Vue实例的生命周期

2018-09-12  本文已影响0人  我打过猴
  <div id="app"></div>
    <script>
        var vm = new Vue({
            el:'#app',
            template:"<div> {{test}}</div>",
            data:{
                test:'hello world'
            },
            //
            beforeCreate:function () {
                console.log("beforeCreate")
            },
            created:function () {
                console.log('created')
            },
            beforeMount:function () {
                console.log(this.$el)
                console.log('beforeMount')
            },
            mounted:function () {
                console.log(this.$el)
                console.log('mounted')
            },
            // destroy方法调用之前调用
            beforeDestroy:function () {
                console.log('beforeDestroy')
            },
            // destroy方法调用之后调用
            destroyed:function () {
                console.log('destroyed')
            },
            // date数据改变之前调用
            beforeUpdate:function () {
                console.log('beforeUpdate')
            },
            // date数据改变之后调用
            update:function () {
                console.log('update')
            }
        })

    </script>
上一篇下一篇

猜你喜欢

热点阅读