1.前言:ionic7以后官方推荐项目插件使用capacitor插件,因为capacitor插件并不丰富所以往往需要用到cordova插件库。
2.官网说明:
capacitor使用cordova Plugins官方说明
Installing Cordova Plugins
Capacitor plugins are installed using your regular package manager and then synced to the native project(s). The installation process is the same for Cordova plugins in Capacitor.
Install the plugin, sync, and then finish any required native project configuration (see Variables and Hooks):
npm install cordova-plugin-name
npx cap sync
If the Cordova plugin has an @awesome-cordova-plugins wrapper, you can also install it for TypeScript support:
npm install @awesome-cordova-plugins/plugin-name
3.示例
ionic+capacitor项目中使用实现ble蓝牙插件使用
1.安装ble插件
npm i cordova-plugin-ble-central
npm install @awesome-cordova-plugins/ble
2.同步
npx cap sync
3.查看列出所有插件
npx cap ls
4.正常的构建
ionic capacitor build android