如何应用。 Vue.js中的promise中的someFunction?

时间:2019-01-13 10:29:16

标签: vue.js

我不会将this.func应用于promise.then范围,但这是“未定义的”。 这是我的代码:

          const $self = this;
          this.myApi(params).then((res) => {        
             $self.func(res);
          });

给我这个错误:$ self未定义。

此代码可以正常工作:

         let func = this.myFunc;
         this.myApi(params).then((res) => {        
              func(res);
         });

我不理解它们之间的区别。

0 个答案:

没有答案