gpt4 book ai didi

android - 为什么跨平台 Cordova 插件需要 2 个 Javascript 文件?

转载 作者:行者123 更新时间:2023-11-29 16:14:03 26 4
gpt4 key购买 nike

在此article here ,我引用:

Catch about different Platforms Before it comes as a surprise to you, let me clarify some things. Say you are developing a Phonegap plugin for 2 platforms: iOS and Android. One might assume that we need to churn out: a single JavaScript file that will be used on both iOS and Android; one Java file for Android One .h and One .m for iOS
However, in reality you will need to churn out: one Javascript file for Android, along with a Java file for Android; a different Javascript file for iOS, alone with pair of .h and .m file for iOS. Both Javascript files can (and should) have the same interface for the developer who consumes it, but the implementations of each interface would be different.

如果 native 方法的名称都相同,为什么还需要 2 个 Javascript 文件?我已经创建了一个 iOS 插件(带有相应的 .js 文件),现在我正在创建 Android 端,我不明白为什么我需要一个单独的 .js 用于 Android 端。有什么想法为什么他们会无缘无故地强调这一点?

最佳答案

这取决于您使用的 PhoneGap/Apache Cordova 版本。在以前的版本中,PhoneGap.exec() 方法签名在 iOS 和 Android 之间是不同的。从 1.7.0 开始,可能早至 1.5.0,方法签名是相同的。无论您在哪个平台上运行,您都应该能够为您的插件使用相同的 .js 文件。

cordova.exec(success, fail, service, action, args);

我将创建一个问题来清理 wiki 说明。

关于android - 为什么跨平台 Cordova 插件需要 2 个 Javascript 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810568/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com