es6 call class methods from within same class

2019-03-23 10:34发布

I'm trying to call a class method in my class form a neighboring method as shown in the example below.

import blah from './blaha';

export default class myclass{
  constructor(con) {
    this.config = con;
  }

  async meth1(paramA) {
    //do_stuff...
  }

    meth2(paramB) {
     //attempt to call meth1()
  }

}

I would like to call a method from within a different method using es6 class styles.

1条回答
Evening l夕情丶
2楼-- · 2019-03-23 11:17

Use this

import blah from './blaha';

export default class myclass{
  constructor(con) {
    this.config = con;
  }

  async meth1(paramA) {
    //do_stuff...
  }

  meth2(paramB) {
     this.meth1()
  }
}
查看更多
登录 后发表回答