PhoneGap插件,为什么每个平台(Android,iOS)的Javascript部分不同?

PhoneGap插件,为什么每个平台(Android,iOS)的Javascript部分不同?,第1张

概述关于PhoneGap插件的编码,PhoneGapWiki说:SayyouaredevelopingaPhoneGapPluginfor2platforms:iOSandAndroid.Onemightassumethatweneedtochurnout:AsingleJavaScriptfilethatwillbeusedonbothiOSandAndroidOneJavafileforAndroid

关于PhoneGap插件的编码,PhoneGap Wiki说:

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.

我的问题是:为什么每个平台需要2个JavaScript文件?
这是插件的JavaScript部分的样子:

var filePlugin = function() {};filePlugin.prototype.read = function(data, successCallback, failureCallback) {return PhoneGap.exec(            successCallback,           failureCallback,            'filePlugin',          'read',                      [data]);       };PhoneGap.addConstructor(function() {PhoneGap.addplugin("filePlugin", new filePlugin());});

我在那里看不到平台相关的内容,那么为什么维基说每个平台都需要自己的JavaScript文件?

可能是我错了,所以我需要您的帮助;)

谢谢

解决方法:

我认为exec API有所不同,但是自从我进行任何PhoneGap开发以来,他们一直在努力使其相同.而且,如果您查看关于PhoneGap.exec的iOS和Android插件开发的各个页面,它们的外观会相同.另请注意,您所指的Wiki上的文本似乎是nearly on year old.

总结

以上是内存溢出为你收集整理的PhoneGap插件,为什么每个平台(Android,iOS)的Javascript部分不同?全部内容,希望文章能够帮你解决PhoneGap插件,为什么每个平台(Android,iOS)的Javascript部分不同?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1072442.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存