【问题标题】:Typescript with Api.AI in Ionic 2Ionic 2 中带有 Api.AI 的打字稿
【发布时间】:2017-06-22 14:26:28
【问题描述】:

我在使用 Typescript 应用程序在 Ionic 2 Angular 2 中导入我的 ApiAIPlugin 时遇到问题

我已经通过 ionic plugin add cordova-plugin-apiai comamnd 添加了插件,它在 config.xml 中:

<plugin name="cordova-plugin-apiai" spec="~1.7.4"/>

但我不知道如何将它导入到我的 home.ts 文件中, 我已经尝试添加

declare var window: any

在我的@Component({}) 上方 并尝试像这样在构造函数中使用它:

window.plugins.ApiAIPlugin.init({...})

但是在浏览器和模拟器中我都得到: 无法读取未定义的属性“ApiAIPlugin”...

有人可以帮我吗?

附言使用this link尝试上述的事情

【问题讨论】:

    标签: angular typescript ionic2 dialogflow-es


    【解决方案1】:

    ApiAIPlugin 是插件的全局对象。 您应该直接声明全局对象。

    declare var ApiAIPlugin:any;
    

    并使用

    ApiAIPlugin.init({...})
    

    或者试试

     declare var window:any;
    

    和:

    window.ApiAIPlugin.init({})
    

    【讨论】:

    猜你喜欢
    • 2017-10-21
    • 1970-01-01
    • 1970-01-01
    • 2019-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多