错误:类型“导航器"上不存在属性“通知" [英] Error: Property 'notification' does not exist on type 'Navigator'

查看:77
本文介绍了错误:类型“导航器"上不存在属性“通知"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用离子插件 cordova-plugin-dialogs ,该插件正在工作,我可以调用 navigator.notification.alert()和创建一个本机警报提示,但是无论何时构建我的应用程序,我都会收到以下控制台错误:

I'm attempting to use the ionic plugin cordova-plugin-dialogs, the plugin is working and I am able to call navigator.notification.alert() and create a native alert prompt but whenever my app builds, I get the following console error:

错误TS2339:类型导航器"上不存在属性通知".

error TS2339: Property 'notification' does not exist on type 'Navigator'.

我在网上阅读到这可能与类型有关,但是我已经确认安装了此插件的类型.

I read online that this could be related to types but I have confirmed that the types for this plugin are installed.

推荐答案

我解决的方法是将其添加到我的types.json中:

The way I solved was to add this to my typings.json:

    "dialogs": "github:apache/cordova-plugin-dialogs/types/index.d.ts"

我的项目很旧,仍然使用打字.我使用grunt进行构建,所以我安装了打字.

My project is old and still use typings. I use grunt to build, so I instal the typings.

这篇关于错误:类型“导航器"上不存在属性“通知"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆