官方文档:[url]http://cordova.apache.org/docs/zh/3.5.0/index.html[/url]
命令详解: [url]http://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html#The%20Command-Line%20Interface[/url]
一些部署和配置参考: [url]http://panyongzheng.iteye.com/blog/2157846[/url]
[color=red]Cordova 3.x 基础(8) -- 几个不可或缺的lib[/color] [url]http://rensanning.iteye.com/blog/2021720[/url]
中文引导: [url]http://inching.org/2014/06/04/cordova-tutorial/[/url]
Cordova 3.x 基础(1) -- 环境搭建(Windows / Android) [url]http://rensanning.iteye.com/blog/2016364[/url]
关于meta viewport中target-densitydpi属性 [url][/url]
phonegap在android中如何退出程序 [url]http://blog.sina.com.cn/s/blog_6d3fcc7e0101ddmz.html[/url]
[color=red][b]官方插件:[/b][/color]
1. cordova plugin add org.apache.cordova.dialogs 用于实现alret,confim等方法
2. cordova plugin add org.apache.cordova.console 实现输出调试信息
3. cordova plugin add org.apache.cordova.inappbrowser 使用内置浏览器打开连接
4. cordova plugin add com.phonegap.plugins.barcodescanner 条形码 [url]https://build.phonegap.com/plugins/261[/url]
5. PhonegapOCRPlugin iOS 扫描插件
5. cordova plugin add https://github.com/albertarvesu/image-scanner-cordova-plugin.git 扫描插件
[color=darkblue][b]Local Storage API methods.[/b][/color]
[color=darkblue]localStorage.getItem():[/color] Returns the value associated with the key.
[color=darkblue]localStorage.setItem(): [/color]Saves the specified key-value pair.
[color=darkblue]localStorage.removeItem(): [/color]Removes the item associated with the key argument.
[color=darkblue]localStorage.clear(): [/color]Removes all items saved in localStorage.
安装和创建例子
[color=darkblue]
1. sudo yum -y install npm
2. sudo npm install -g cordova
3. cordova create hello com.example.hello HelloWorld
4. cordova platform add android
5. cordova platform rm android //删除某个平台的代码
6. cordova build //编译,
A: cordova build ios
B: cordova prepare ios
cordova compile ios
7. cordova emulate android 或者 cordova run --emulator android //运行到svd
8. cordova android 或者 cordova run android //运行到手机
9. ordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git 或者 cordova plugin add org.apache.cordova.dialogs //增加插件,到工程根目录执行
[/color]
PhoneGap/Cordova3.0+ 使用,以及添加插件笔记 [url][/url]
[b]添加org.apache.cordova.dialogs插件例子:用于实现alret,confim等方法。[/b],祥解: [url]http://plugins.cordova.io/#/package/org.apache.cordova.dialogs[/url]
1. cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git //增加插件,到工程根目录执行
2. 在index.js的app对象里面加入
alertDismissed: function () {
// do something
},
showAlert: function () {
navigator.notification.alert(
'You are the winner!', // message
app.alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}
3. 在index.html加入
<p><a href="#" onclick="app.showAlert();return false;">点链接</a></p>
[color=red][b]ajax技术[/b][/color],注意包含编辑头部信息。
服务器:cakephp代码
public function callAjax()
{
$a=$this->request->header('username');//获得头部信息
$dlist = array(
"rows" => array("11", "22", "33","11", "22", "33","11", "22", "33"),
"status" => 1);
return new CakeResponse(array('body' => json_encode($dlist), 'status' => 200));
}
客户端:
$("#ajax_test").on("tap",function(){
$.ajax({
url: "http://192.168.0.198/Demos/callAjax",
data: [],
type: 'POST',
dataType: 'json',
headers: {
"username":"106110454@qq.com"//传入头部信息,比如验证信息等。
},
success: function (data, textStatus) {
navigator.notification.alert(
'成功='+ $.toJSON(data), // message
app.alertDismissed, // callback
'远程调用', // title
'确定' // buttonName
);
},
error: function (xhr, textStatus, errorThrown) {
navigator.notification.alert(
'失败='+xhr, // message
app.alertDismissed, // callback
'远程调用', // title
'确定' // buttonName
);
}
});
});
[color=red][b]应用图标[/b][/color]
[url]http://cordova.apache.org/docs/en/edge/config_ref_images.md.html#Icons%20and%20Splash%20Screens[/url]
<icon src="res/icon.png" platform="android" width="57" height="57" density="mdpi" />
[color=red][b]调试方式: [/b][/color]
1. GapDebug, 不支持Linux
2. Mock 模式调试技术, Phonegap-desktop 项目, 一直没更新。
3. 代理模式调试技术weinre, Weinre 无法实现 JavaScript 动态调试
[b][color=blue]Weinre:[/color][/b] [url][/url]
sudo npm -g install weinre
weinre --boundHost 192.168.0.198 --httpPort 8081 --all
/usr/lib/node_modules/weinre/web/target/target-script-min.js加入工程
[color=red][b]问题:[/b][/color]
[color=red]1. ANDROID_HOME is not set and "android" command not in your PATH[/color],
明明环境变量都弄好了,执行android也能打开了,为什么还报错?