Home >Web Front-end >JS Tutorial >How to implement calling between methods in vue

How to implement calling between methods in vue

亚连
亚连Original
2018-06-07 10:53:145202browse

Below I will share with you an article about how to implement methods in Vue. One method calls another method. It has a good reference value and I hope it will be helpful to everyone.

vue is in the same component;

A method in methods calls another method in methods

can be called when this. $options.methods.test2();

##this.$options.methods.test2();One method calls another method ;

new Vue({ 
 el: '#app', 
 data: { 
  test:111, 
 }, 
 methods: { 
  test1:function(){ 
   alert(this.test) 
  }, 
  test2:function(){ 
   alert("this is test2") 
   alert(this.test) //test3调用时弹出undefined 
  }, 
  test3:function(){ 
   this.$options.methods.test2();//在test3中调用test2的方法 
  } 
 } 
})

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Use ref in vue to let the parent component call the child component

How to realize the web front-end page generation exe

How to implement ajax front-end and back-end cross-domain requests

The above is the detailed content of How to implement calling between methods in vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn