“void"类型上不存在属性“then" [英] Property 'then' does not exist on type 'void'
本文介绍了“void"类型上不存在属性“then"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该如何处理 Typescript 错误:
How should I handle the Typescript error:
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 => {}
);
}
}
推荐答案
函数share
的定义返回void,你也可以在错误信息中看到
The definition of the function share
returns void as you can also see in the error message
static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): void {}
因此在调用share
这篇关于“void"类型上不存在属性“then"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文