【问题标题】:Ionic 5 plugin undefined on IOSIonic 5 插件在 IOS 上未定义
【发布时间】:2021-03-13 15:05:29
【问题描述】:

我在 Ionic 应用上安装了 TextToSpeech Cordova 插件:

"@ionic-native/text-to-speech": "^5.30.0",
"cordova-plugin-tts": "^0.2.3",

并在我的 vue 文件中使用它:

import { Plugins } from "@capacitor/core";
const { TextToSpeech } = Plugins;


...
methods: {
    tts(text) {
      TextToSpeech.speak(text)
        .then(() => console.log("Success Speach"))
        .catch((reason) => console.log(reason));
    },
...

console.log(TextToSpeech);

我正在使用电容器

IOS 当我尝试在 IOS 上使用插件时:出现未知错误:error {} 当我打印插件时,我得到:[log] - undefined

浏览器 当我尝试使用插件时,它会按预期打印:TextToSpeech 没有网络实现。 当我打印插件时,我得到:Proxy {}

所以它在浏览器中工作并加载,但在设备上没有。

【问题讨论】:

    标签: vue.js cordova ionic-framework cordova-plugins ionic-native


    【解决方案1】:

    我找到了解决办法。

    第一次更新@ionic-native/core

    npm uninstall --save @ionic-native/core && npm install --save @ionic-native/core@latest

    像这样导入插件

    import { TextToSpeech } from "@ionic-native/text-to-speech";

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-12
      • 2021-08-07
      • 1970-01-01
      • 2023-03-20
      • 2018-10-25
      • 1970-01-01
      • 2021-12-09
      • 2021-01-01
      相关资源
      最近更新 更多