zoukankan      html  css  js  c++  java
  • vue methods 中方法的相互调用

    vue在同一个组件内;方法之间经常需要互相调用。

    methods中的一个方法如何调用methods中的另外一个方法呢?

    可以在调用的时候使用  this.$options.methods.test2();

    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的方法

            }

        }

    })

     

  • 相关阅读:
    条件
    循环
    列表
    字典
    集合
    公共操作
    函数-2
    函数-1
    函数加强
    文件操作
  • 原文地址:https://www.cnblogs.com/ranyonsue/p/9681753.html
Copyright © 2011-2022 走看看