CORDOVA介绍

来源:互联网 发布:淘宝投诉电话人工服务 编辑:程序博客网 时间:2024/05/22 17:07


Overview(概述)

Apache Cordova is an open-source mobile development framework.(Cordova是一个开源的移动开发框架)

It allows you to use standard web technologies - HTML5, CSS3, and JavaScript for cross-platform development.(它允许你使用WEB开发技术(HTML5、CSS3、JavaScript)进行跨平台开发)

Applications execute within wrappers targeted to each platform, and rely on standards-compliant API bindings to access each device's capabilities such as sensors, data, network status, etc.(应用在每个平台的封装器中执行,并且依赖规范的API对设备进行高效的访问,比如传感器、数据、网络状态等等。)

Use Apache Cordova if you are:(在下述场景中您可以使用Cordova)

a mobile developer and want to extend an application across more than one platform, without having to re-implement it with each platform's language and tool set.(一位想拓展自己应用至多个平台,且没有具备各个平台的编程语言和工具实现能力的移动开发人员)

a web developer and want to deploy a web app that's packaged for distribution in various app store portals.(一位想部署一个WEB应用打包至不同的手机市场的WEB开发人员)

a mobile developer interested in mixing native application components with a WebView (special browser window) that can access device-level APIs, or if you want to develop a plugin interface between native and WebView components.(一位对通过可以访问设备级API的WebView(特殊的浏览窗口)和本地应用组件混合开发感兴趣的移动开发人员,或如果你想开发一个在本地和WebView组件的插件接口)

Architecture(架构)

There are several components to a cordova application. The following diagram shows a high-level view of the cordova application architecture.(下述是几个关于Cordova应用的组件。下面的图表显示了一个高级别的Cordova的应用架构)

WebView(特殊的浏览窗口)

The Cordova-enabled WebView may provide the application with its entire user interface.(Cordova-enabled WebView能够提供给应用全部的用户接口)

 On some platforms, it can also be a component within a larger, hybrid application that mixes the WebView with native application components. (SeeEmbedding WebViews for details.)(在一些平台中,它常常作为本地应用组件和WebView混合的一个大型的,混合应用的组件。(详见Embedding WebViews))

Web App(web应用)

 This is the part where your application code resides. The application itself is implemented as a web page, by default a local file namedindex.html, that references CSS, JavaScript, images, media files, or other resources are necessary for it to run. (这里就是你程序代码存放的部分。应用自身实现就如一个web页面,通过默认的本地叫做index.html的文件,涉及到CSS、JavaScript、images、媒体文件、或者其他运行时需要的其它资源。)

The app executes in a WebView within the native application wrapper, which you distribute to app stores.(应用执行在一个你从应用商店上发布的本地应用封装器中)

This container has a very crucial file - config.xml file that provides information about the app and specifies parameters affecting how it works, such as whether it responds to orientation shifts.(容器有一个非常重要的文件(提供应用信息和影响其运行的特殊参数的config.xml文件,比如对定向转移的响应))

Plugins(插件)

 Plugins are an integral part of the cordova ecosystem. (插件是Cordova生态系统的核心部分)

They provide an interface for Cordova and native components to communicate with each other and bindings to standard device APIs. This enables you to invoke native code from JavaScript.(它们提供了一个Cordova和本地组件交互的接口和绑定标准设备的API。这能让你通过JavaScript调用本地代码)

Apache Cordova project maintains a set of plugins called the Core Plugins. These core plugins provide your application to access device capabilities such as battery, camera, contacts, etc.(Apache Cordova项目包含一系列叫做核心插件的插件集合。这些核心的插件能让你的应用高效的访问设备,比如电池、摄像头、联系人等等。)

In addition to the core plugins, there are several third-party plugins which provide additional bindings to features not necessarily available on all platforms.(除了这些核心的插件之外,这些还有一些提供在所有平台上不必要的额外特征的第三方插件。)

 You can search for Cordova plugins using plugin search or npm. You can also develop your own plugins, as described in the Plugin Development Guide. Plugins may be necessary, for example, to communicate between Cordova and custom native components.(你可以通过插件搜索或npm进行查找Cordova插件。你也可以开发你自己的插件,正如《插件开发指导书》中所述。插件可能是需要的,比如,插件可以实现自定义本地组件和Cordova的交互)

NOTE: When you create a Cordova project it does not have any plugins present. This is the new default behavior. Any plugins you desire, even the core plugins, must be explicitly added.(注意:当你想创建一个Cordova项目而它当前没有插件时。这里有一种新的默认的方式。你想要的插件,甚至核心插件,必须明确的添加。)

Cordova does not provide any UI widgets or MV* frameworks. (Cordova没有提供任何UI窗体或者MVVM框架)

Cordova provides only the runtime in which those can execute.(Cordova仅仅提供其运行的环境)

 If you wish to use UI widgets and/or an MV* framework, you will need to select those and include them in your application.(如果你想使用UI窗口或MVVM框架,你将需要去选择它们并且将它们包含在你的应用中)

Development Paths(开发路径)

 Cordova provides you two basic workflows to create a mobile app. (Cordova提供给你两个基本的思路去创建一个手机应用)

While you can often use either workflow to accomplish the same task, they each offer advantages:(当然你可以提供完美同样的路线去完成同样的任务,它具有的优点是:)

  • Cross-platform (CLI) workflow(跨平台(CLI)路线): Use this workflow if you want your app to run on as many different mobile operating systems as possible, with little need for platform-specific development. (如果你想你的应用能够运行尽可能多的不同的移动操作系统,通过一些不同平台开发,你就使用这种路线)This workflow centers around the cordova CLI.(这种路线重点在于Cordova CLI) The CLI is a high-level tool that allows you to build projects for many platforms at once, abstracting away much of the functionality of lower-level shell scripts. (CLI是一个允许你马上为多个平台构建项目,并从许多低级别shell脚本功能抽象出来)The CLI copies a common set of web assets into subdirectories for each mobile platform, makes any necessary configuration changes for each, runs build scripts to generate application binaries.(CLI给每个移动平台的子目录中复制了一些WEB的有利方面,使任何需要的配置的变更到每个平台,运行脚本) The CLI also provides a common interface to apply plugins to your app.(CLI也提供了一个在你应用上应用插件的公共接口) To get started follow the steps in theCreate your first app guide. (可以从 创建你的应用 中下面的步骤开始)Unless you have a need for the platform-centered workflow, the cross-platform workflow is recommended.(除非你有平台集成的必要,这种跨平台是比较推荐的)

  • Platform-centered workflow(平台集中路线): Use this workflow if you want to focus on building an app for a single platform and need to be able to modify it at a lower level. You need to use this approach, for example, if you want your app to mix custom native components with web-based Cordova components, as discussed in Embedding WebViews. As a rule of thumb, use this workflow if you need to modify the project within the SDK. This workflow relies on a set of lower-level shell scripts that are tailored for each supported platform, and a separate Plugman utility that allows you to apply plugins. While you can use this workflow to build cross-platform apps, it is generally more difficult because the lack of a higher-level tool means separate build cycles and plugin modifications for each platform.

When first starting out, it may be easiest to use the cross-platform workflow to create an app, as described inCreate your first app guide. You then have the option to switch to a platform-centered workflow if you need the greater control the SDK provides.

NOTE: Once you switch from the CLI-based workflow to one centered around the platform-specific SDKs and shell tools, you can't go back. The CLI maintains a common set of cross-platform source code, which on each build it uses to write over platform-specific source code. To preserve any modifications you make to the platform-specific assets, you need to switch to the platform-centered shell tools, which ignore the cross-platform source code, and instead relies on the platform-specific source code.



0 0
原创粉丝点击