VueJS accessing a method from another method

后端 未结 3 1997
野趣味
野趣味 2020-12-05 05:59

I\'m using VueJS to make a simple enough resource management game/interface. At the minute I\'m looking to activate the roll function every 12.5 seconds and use

3条回答
  •  既然无缘
    2020-12-05 06:42

    You can use vm.methodName();

    Example:

    let vm = new Vue({
      el: '#app',
      data: {},
      methods: {
        methodA: function () {
          console.log('hello');
        },
        methodB: function () {
          // calling methodA
          vm.methodA();
        }
      },
    })
    

提交回复
热议问题