混合开发app框架(混合开发app框架结构)

dylinchen 937 2022-12-11

本文目录一览:

APP原生开发与混合开发是什么意思

1.原生开发(Native App开发):像盖房子一样,先打地基然后浇地梁、房屋结构、一砖一瓦、钢筋水泥、电路走向等,原生APP同理:通过代码从每个页面、每个功能、每个效果、每个逻辑、每个步骤全部用代码写出来,一层层,一段段全用代码写出来

此种APP的数据都保存在本地,APP能及时调取,所以相应速度及流畅性有保障

2.混合开发(HTML5开发):这个就相当于一种框架开发,说白了就是网页;该模式通常由“HTML5云网站+APP应用客户端”两部份构成,APP应用客户端只需安装应用的框架部份,而应用的数据则是每次打开APP的时候,去云端取数据呈现给手机用户。

混合APP还有一种是套壳APP,套壳APP就是用H5的网页打包成APP,虽然是APP能安装到手机上,但是每个界面,全部是网页。此种APP数据都保存在云端,用户每次访问都需要从云端调取全部内容,这样就容易导致反应慢,每打开一个网页或点一个按钮都需要等半天。

混合开发的优缺点:

优点是:

1、开发效率高,节约时间同一套代码Android和IOS基本都可用

2、更新和部署比较方便,不需要每次升级都要上传到App Store进行审核了,只需要在服务器端升级就可以

3、代码维护方便、版本更新快,降低产品成本

缺点是:

1、由于不能直接操控硬件有些方面性能不是很好

2、另外有技术比较新版本的兼容性比较差,还有就是即懂原生开发又懂H5开发的高端人才难找。

混合App开发是未来的趋势,目前混合开发中使用的技术也很多,主要的混合开发技术有jQuery Mobile、React Native、Cordova、APICloud、AppCan等。虽然混合开发能够提高效率节省成本,但也有很多的限制,除了硬件、缓存等的限制,各大平台之间的兼容性也不足。有的也比较消耗资源。

1.jpg


APP混合式开发框架太多了,该怎么选择

如果是商业用途的软件,不建议用第三方的框架去做。这些第三方的都是大公司员工为了晋级和kpi做出的产物,很多维护了一段时间就不再维护了,因为框架在不同系统版本上以及未来的新版本及系统上的适配是非常耗费精力和财力的,大公司有很多机器和专门的qa去做这个东西,而且在商业上的收获很少。一段时间后就不再维护了。如果你要做可以挑选一两个用的比较多的,然后吃透起原理,自己弄。或者就用原始api进行按部就班的开发。

如果是商业软件,切记不要使用这些第三方的混合式开发框架。短时间不会有什么问题,一旦停止维护。你就哭去吧。

如果是自己做个demo涨涨知识就无所谓了

混合开发之uni-app

uni-app App端内置weex渲染引擎,提供原生渲染能力

然而, Weex并不是一个前端框架 。实际上,前端框架仅仅是 Weex 的语法层或称之为 DSL (Domain-specific Language),它们与原生渲染引擎是分离的。换句话说,Weex 并不依赖于特定的前端框架,随着前端技术的发展,Weex 也可以集成更多广泛使用的前端框架。

以往的 weex ,有个很大的问题是它只是一个高性能的渲染器,没有足够的API能力,使得开发时非常依赖原生工程师协作,开发者本来想节约成本,结果需要前端、iOS、Android 3拨人开发,适得其反。而 nvue 解决了这个大问题,让前端工程师可以直接开发完整 App,并提供原生插件的市场交易和云打包。这些组合方案,开发者切实的提高效率、降低成本。

如果你是web前端,不熟悉 weex,那么建议你仍然以使用 vue 为主,在App端某些 vue 表现不佳的场景下使用 nvue 作为强化补充:

uni-app App 端内置 HTML5+ 引擎,让 js 可以直接调用丰富的原生能力。

小程序及 H5 等平台是没有 HTML5+ 扩展规范的,因此在 uni-app 调用 HTML5+ 的扩展规范时,需要注意使用条件编译。否则运行到h5、小程序等平台会出现 plus is not defined错误。

在普通的 H5+ 项目中,需要使用 document.addEventListener 监听原生扩展的事件。

uni-app 中,没有 document。可以使用 plus.globalEvent.addEventListener 来实现(注意manifest中需开启新编译器,即自定义组件模式"usingComponents":true)。

同理,在 uni-app 中使用 Native.js 时,一些 Native.js 中对于原生事件的监听同样需要按照上面的方法去实现。

注意:旧编译器(非自定义组件模式)不支持 plus.globalEvent 这个对象。

混合app开发有哪些优秀的前端框架可用

jquery mobile , bootstrap 都是很优秀的前端框架,bootstrap 现在应用的比较多,jquery mobile 么如果你习惯使用jquery,用起来会比较方便

android 混合开发 框架有哪些

Cordova是一个广泛使用的Hybrid开发框架,它提供了一套js和Native交互规范

在Cordova的 SystemWebViewEngine 类中可以看到

private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {

if ((Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN_MR1)) {

Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");

// Bug being that Java Strings do not get converted to JS strings automatically.

// This isn't hard to work-around on the JS side, but it's easier to just

// use the prompt bridge instead.

return;

}

webView.addJavascriptInterface(new SystemExposedJsApi(bridge), "_cordovaNative");

}

因此当Android系统高于4.2时,Cordova还是使用 addJavascriptInterface 这种方式,因为这个方法在高版本上安全而且简单,低于4.2的时候,用什么方法呢?

答案是 WebChromeClient.onJsPrompt 方法

WebView可以设置一个 WebChromeClient 对象,它可以处理js的3个方法

onJsAlert

onJsConfirm

onJsPrompt

这3个方法分别对应js的 alert 、 confirm 、 prompt 方法,因为只有 prompt 接收返回值,所以js调用一个Native方法后可以等待Native返回一个参数。下面是 cordova.js 中的一段代码:

/**

* Implements the API of ExposedJsApi.java, but uses prompt() to communicate.

* This is used pre-JellyBean, where addJavascriptInterface() is disabled.

*/

module.exports = {

exec: function(bridgeSecret, service, action, callbackId, argsJson) {

return prompt(argsJson, 'gap:'+JSON.stringify([bridgeSecret, service, action, callbackId]));

},

setNativeToJsBridgeMode: function(bridgeSecret, value) {

prompt(value, 'gap_bridge_mode:' + bridgeSecret);

},

retrieveJsMessages: function(bridgeSecret, fromOnlineEvent) {

return prompt(+fromOnlineEvent, 'gap_poll:' + bridgeSecret);

}

};

然后只要在 onJsPrompt 方法中使用 CordovaBridge 来处理js的prompt调用

/**

* Tell the client to display a prompt dialog to the user. If the client returns true, WebView will assume that the client will handle the prompt dialog and call the appropriate JsPromptResult method.

* p/

* Since we are hacking prompts for our own purposes, we should not be using them for this purpose, perhaps we should hack console.log to do this instead!

*/

@Override

public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {

// Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.

String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);

if (handledRet != null) {

result.confirm(handledRet);

} else {

dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {

@Override

public void gotResult(boolean success, String value) {

if (success) {

result.confirm(value);

} else {

result.cancel();

}

}

});

}

return true;

}

android 混合开发 用什么框架好

Cordova是一个广泛使用的Hybrid开发框架,它提供了一套js和Native交互规范

在Cordova的 SystemWebViewEngine 类中可以看到

private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {

if ((Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN_MR1)) {

Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");

// Bug being that Java Strings do not get converted to JS strings automatically.

// This isn't hard to work-around on the JS side, but it's easier to just

// use the prompt bridge instead.

return;

}

webView.addJavascriptInterface(new SystemExposedJsApi(bridge), "_cordovaNative");

}

因此当Android系统高于4.2时,Cordova还是使用 addJavascriptInterface 这种方式,因为这个方法在高版本上安全而且简单,低于4.2的时候,用什么方法呢?

答案是 WebChromeClient.onJsPrompt 方法

WebView可以设置一个 WebChromeClient 对象,它可以处理js的3个方法

onJsAlert

onJsConfirm

onJsPrompt

这3个方法分别对应js的 alert 、 confirm 、 prompt 方法,因为只有 prompt 接收返回值,所以js调用一个Native方法后可以等待Native返回一个参数。下面是 cordova.js 中的一段代码:

/**

* Implements the API of ExposedJsApi.java, but uses prompt() to communicate.

* This is used pre-JellyBean, where addJavascriptInterface() is disabled.

*/

module.exports = {

exec: function(bridgeSecret, service, action, callbackId, argsJson) {

return prompt(argsJson, 'gap:'+JSON.stringify([bridgeSecret, service, action, callbackId]));

},

setNativeToJsBridgeMode: function(bridgeSecret, value) {

prompt(value, 'gap_bridge_mode:' + bridgeSecret);

},

retrieveJsMessages: function(bridgeSecret, fromOnlineEvent) {

return prompt(+fromOnlineEvent, 'gap_poll:' + bridgeSecret);

}

};

然后只要在 onJsPrompt 方法中使用 CordovaBridge 来处理js的prompt调用

/**

* Tell the client to display a prompt dialog to the user. If the client returns true, WebView will assume that the client will handle the prompt dialog and call the appropriate JsPromptResult method.

* p/

* Since we are hacking prompts for our own purposes, we should not be using them for this purpose, perhaps we should hack console.log to do this instead!

*/

@Override

public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {

// Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.

String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);

if (handledRet != null) {

result.confirm(handledRet);

} else {

dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {

@Override

public void gotResult(boolean success, String value) {

if (success) {

result.confirm(value);

} else {

result.cancel();

}

}

});

}

return true;

}


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何使用JJWT及JWT讲解和工具类
下一篇:两个线程(两个线程并发执行以下代码,假设a是全局变量)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~