Mutual calling of methods in vue

Vue is in the same component; methods often need to call each other.

How does a method in methods call another method in methods?

You can use this.$options.methods.test2(); when calling.

new View({

     the: '#app',

     data: {

         test:111,

     },

     methods: {

          test1:function(){

              alert(this.test)

         },

         test2:function(){

             alert("this is test2")

             alert(this.test) //undefined pops up when test3 is called

        },

        test3:function(){

                this.$options.methods.test2();//Call test2 method in test3

        }

    }

})

 

WeChat official account search: Li Datou . (or scan the QR code) Come and play with me.

More [front-end technology group] and [recommended positions] resources are waiting for you.

I also invite everyone to drink milk tea on the official account from time to time!

If you want to chat with me or have any questions, you can find me on the official account.

Waiting for you~

Guess you like

Origin blog.csdn.net/ljy_1024/article/details/89968000