cordova常用命令
cordova create hello com.example.hello "HelloWorld" //创建一个项目
cd hello //切换到文件夹
cordova platform add android //添加安卓平台
cordova build android //打包文件
cordova run android //运行模拟器
cordova 插件安装的命令
查看当前项目已安装的插件:
$ cordova plugin ls
获取设备信息插件:
$ cordova plugin add cordova-plugin-device
获取通知插件:
$ cordova plugin add cordova-plugin-dialogs
设备振动的插件调用 :
navigator.notification.vibrate(2000);
GPS插件的安装命令:
$ cordova plugin add cordova-plugin-geolocation
摄像头插件安装命令:
$ cordova plugin add cordova-plugin-camera
设备联网信息
cordova plugin add cordova-plugin-network-information
摄像头
getPhoto:function(){
navigator.notification.confirm("",app.confirmCall,"选择头像",["从相册选择","拍照"])
},
confirmCall:function(index){
var type;
if(index==1){
type=Camera.PictureSourceType.PHOTOLIBRARY;
}else{
type=Camera.PictureSourceType.CAMERA;
}
var cameraOptions={
sourceType:type,
destinationType:type
};
navigator.camera.getPicture(
app.picSucc,
app.picErr,
cameraOptions
);
},
picSucc:function(image){
alert(image);
var elem=document.getElementById("logo");
elem.style.backgroundImage="url("+image+")";
elem.style.backgroundSize="100% auto";
},
picErr:function(err){
alert(err);
}