vuejs中methods中的互相调用
vuejs 中 methods 中的方法可以互相调用吗
如以下的代码,想要在 test3 中调用 test2 的代码。
new Vue({ |
methods 中的 function 中的 this 指向 vue 实例,没有任何的 this 绑定,所以肯定访问不到。
可以尝试
this.$options.methods.test2.bind(this)(); |
这是 vue 的调用方式
/** |
vuejs 中 methods 中的方法可以互相调用吗
如以下的代码,想要在 test3 中调用 test2 的代码。
new Vue({ |
methods 中的 function 中的 this 指向 vue 实例,没有任何的 this 绑定,所以肯定访问不到。
可以尝试
this.$options.methods.test2.bind(this)(); |
这是 vue 的调用方式
/** |
本文作者:WhyLiam
本文链接:https://blog.naaln.com/2017/01/vuejs-call-method/
版权声明:本文采用 CC BY-NC-ND 4.0 许可协议,转载请注明出处。
首发站点:Why·Liam·Blog (https://blog.naaln.com)