我有一个有趣的用例,我想在两个平台中只有一个平台上使用离子原生插件,即蓝牙串行。所以我想在安卓上使用它,而不是在iOS上。有没有一种方法可以将依赖添加到一个平台上?
发布于 2021-02-05 18:01:05
可以,您可以使用Platform Api来检测平台并编写特定于平台的代码。
在.ts文件中:
import { Platform } from '@ionic/angular';
export class YourPage implements OnInit {
constructor(private platform: Platform){
}
if (this.platform.is('android')) {
// Write your Android Specific code
} else {
console.log('Other Platform')
}
}https://stackoverflow.com/questions/66060255
复制相似问题