相关疑难解决方法(0)

忽略Typescript错误"属性在类型的值上不存在"

在VS2013中,当tsc以代码1退出时,构建停止.在VS2012中不是这种情况.

如何在忽略tsc.exe错误的同时运行我的解决方案?

我收到很多The property 'x' does not exist on value of type 'y'错误,我想在使用javascript函数时忽略这些错误.

javascript typescript visual-studio-2013

193
推荐指数
8
解决办法
23万
查看次数

'Navigator'类型中不存在属性'share'

我需要在我的Ionic应用程序中使用WebShareAPI.

这是我在介绍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');
}
Run Code Online (Sandbox Code Playgroud)

但是,Typescript编译失败,并出现以下错误:

[11:31:11]  typescript: src/pages/channel_home/channel_home.ts, line: 89
            Property 'share' does not exist on type 'Navigator'.
Run Code Online (Sandbox Code Playgroud)

这里有一个可能的原因解释 DOM lib:添加对navigator.share的支持

但是,我想知道一些解决方法,特别是在我的Ionic应用程序中,以及在任何Angular或Typescript应用程序中使WebShareApi工作.

typescript ionic-framework angular

15
推荐指数
5
解决办法
5056
查看次数