我为iOS、安卓和网络制作了一个自定义电容器插件,但当我在浏览器中打开基于电容器的应用程序时,我得到了以下错误信息:
ERROR Error: Uncaught (in promise): MyPlugin does not have web implementation.所以问题似乎是电容找不到插件的web实现。
发布于 2021-05-31 13:14:47
我在运行Capacitor v2.4.7时遇到了这个问题。这似乎是由Plugins对象的解构引起的:
const {MyPlugin} = Plugins;
MyPlugin.myMethod(); // FAIL我发现使用Plugins对象直接避免了这个错误:
Plugins.MyPlugin.myMethod(); // OK来源:https://github.com/ionic-team/capacitor/issues/749#issuecomment-479781137
发布于 2019-09-24 14:56:18
要在Angular应用程序中修复该问题,您必须在app.component.ts中添加以下行:
import {Component} from '@angular/core';
import {MyPlugin} from "capacitor-myplugin";
import {registerWebPlugin} from "@capacitor/core";
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor() {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
registerWebPlugin(MyPlugin);
});
}
}https://stackoverflow.com/questions/58074649
复制相似问题