私のアプリケーションでWebShareAPIを使用する必要があります。プロパティ '共有'がタイプ 'ナビゲータ'に存在しません
ここがIntroducing the Web Share API
if (window.navigator && window.navigator.share) {
window.navigator.share({
title: 'title',
text: 'description',
url: 'https://soch.in//',
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
} else {
alert('share not supported');
}
で提案されているように私のコードですが、活字体のコンパイルは次のエラーで失敗します。
[11:31:11] typescript: src/pages/channel_home/channel_home.ts, line: 89
Property 'share' does not exist on type 'Navigator'.
そうな理由がありますが、ここで DOM lib: add support for navigator.share
を説明私は、WebShareApiを自分のIonicアプリで動作させるいくつかの回避策を知りたいular、Angular、Typescriptのいずれのアプリでも使用できます。
は、あなたは、単に[グローバル](https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-d-tsを使用することはできません私のために働きました。 html)? –
@FlavienVolken、あなたはglobals.d.tsファイルに新しいインタフェースタイプを追加することを意味しますか?変数 'navigator.share'をプロジェクトの異なるレベルで使用する場合は、それが良い選択です。そうでなければ、解答で説明するように進みます。 – edkeveked