离子 6 电容器、电子:Cordova 不可用。确保在 device/simulator 中包含 cordova.js 或 运行

Ionic 6 Capacitor, electron: Cordova is not available. Make sure to include cordova.js or run in a device/simulator

我正在尝试在新的 ionic 6 项目中使用 cordova 插件,但我总是 运行 遇到有关 cordova 的错误。插件已正确安装并显示在插件文件夹中。 我使用 Ionic 6 vue、电容器和 capacitor-community/electron 构建 windows 原生应用程序。 一切正常,但在模拟器中的 运行 cordova 插件上出现此错误:

Native:尝试调用 Printer.print,但 Cordova 不可用。确保在 device/simulator

中包含 cordova.js 或 运行
npm i @capacitor-community/electron
npx cap add @capacitor-community/electron
ionic build
ionic build @capacitor-community/electron && npx cap copy @capacitor-community/electron
npx cap open @capacitor-community/electron

Capacitor 不支持 Web 和 Electron 上的 Cordova 插件,它们仅在 iOS 和 Android 上受支持。

GitHub 上的 Capacitor 有一个未解决的问题:

https://github.com/ionic-team/capacitor/issues/769

遗憾的是,Cordova 插件支持目前仅在 Android 和 iOS 上可用。