extend

Vue.extend

自定义无参数标签

<divid="app">

        <qwe></qwe>

    </div>

 

  varqwe = Vue.extend({

            //模版

            template:"<p><a:href=w>{{q}}</a></p>",

            data:function () {

                return {

                    q:'qwe',

                    w:'www.baidu.com'

                }

            }

        });

这时html中的标签还是不起作用的,因为扩展实例构造器是需要挂载

$mount方法是用来挂载扩展的

  //$mount()手动挂载

        newqwe().$mount('#app');

$destroy() 卸载方法

functiondestroy(){ vm.$destroy(); }

$forceUpdate() 更新方法

vm.$forceUpdate()

$nextTick() 数据修改方法

Vue构造器里的data值被修改完成后会调用这个方法,也相当于一个钩子函数,和构造器里的updated生命周期很像。

functiontick(){

    vm.message="updatemessage";

    vm.$nextTick(function(){

        console.log('message更新完了');

    })

}

猜你喜欢

转载自blog.csdn.net/qq_37199582/article/details/80352875