【发布时间】:2021-05-26 19:46:15
【问题描述】:
我一直在尝试将 Motion 功能添加到我的 Capacitor 应用程序中,尽管像所有其他可以工作的插件一样安装,但 Motion 插件没有出现在我的插件列表或 JavaScript 中的 Capacitor.Plugins 对象中。
像所有其他插件一样,我使用npm install @capacitor/motion 安装,然后与npx cap sync 同步。安装似乎成功,但随后通过npx cap ls 列出插件会显示所有插件除了 Motion。
安装结果:
% npm install @capacitor/motion
added 1 package, and audited 16 packages in 860ms
found 0 vulnerabilities
然后我做了一个npx cap sync 并将更新后的capacitor.js 复制到我的服务器位置。
插件列表结果:
% cap ls
[info] Found 10 Capacitor plugins for android:
@capacitor-community/screen-brightness@1.0.1
@capacitor/browser@1.0.0
@capacitor/dialog@1.0.0
@capacitor/geolocation@1.0.0
@capacitor/haptics@1.0.0
@capacitor/local-notifications@1.0.0
@capacitor/screen-reader@1.0.0
@capacitor/status-bar@1.0.0
@capacitor/text-zoom@1.0.0
@capacitor/toast@1.0.0
[info] Found 10 Capacitor plugins for ios:
@capacitor-community/screen-brightness@1.0.1
@capacitor/browser@1.0.0
@capacitor/dialog@1.0.0
@capacitor/geolocation@1.0.0
@capacitor/haptics@1.0.0
@capacitor/local-notifications@1.0.0
@capacitor/screen-reader@1.0.0
@capacitor/status-bar@1.0.0
@capacitor/text-zoom@1.0.0
@capacitor/toast@1.0.0
[info] Listing plugins for web is not possible.
JavaScript 中Capacitor.Plugins 对象的内容:
Capacitor.Plugins: {
Browser,
Dialog,
Geolocation,
Haptics,
LocalNotifications,
ScreenBrightness,
ScreenReader,
StatusBar,
TextZoom,
Toast,
WebView
}
我应该通过其他方式访问Capacitor.Plugins.Motion 以侦听orientation 事件吗?
谢谢!
【问题讨论】:
标签: cordova ionic-framework capacitor