类型'void'上不存在属性'then'

时间:2016-06-23 08:28:15

标签: typescript ionic2

我应该如何处理Typescript错误:

Property 'then' does not exist on type 'void'

我的代码如下所示:

import {Component} from '@angular/core';
import {SocialSharing} from "ionic-native";

@Component({
  templateUrl: 'build/pages/about/about.html'
})
export class AboutPage {

  constructor() {

  }

  share() {
    SocialSharing.share('Take a look at our app. It is great! Download it from the App Store now.',
        'Take a look at our app. It is great! Download it from the App Store now.', null, null).then(
          res => {},
          err => {}
    );
  }

}

1 个答案:

答案 0 :(得分:1)

函数share的定义返回void,您也可以在错误消息中看到

static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): void {}

因此,在致电then

时,您无法致电share