cordova + ionic 使用中碰到的一些问题

本文总结了在使用cordova和ionic开发过程中遇到的问题及其解决方案,包括Content-Security-Policy缺失、隐藏nav-bar、ng-model与input值同步、在ripple中处理cordova插件错误、解决平台android/AndroidManifest.xml重复问题、处理iframe调用、解决android studio运行错误、加载远程资源失败、键盘遮挡输入框、监听滚动、检查网络并提示、$state.go传参、底部固定按钮和支付问题等。
摘要由CSDN通过智能技术生成
1、No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.
解决办法
index.html 中添加
《meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"》

2、ionic 隐藏 nav-bar
文档上来看,需要在controller中调用    $ionicNavBarDelegate
例如 .controller('DashCtrl', function ($scope, $ionicNavBarDelegate) {
    $ionicNavBarDelegate.showBar(false);
})
但没起作用。最后在模板中使用标签方法
hide - nav - bar = "true"
该方法起作用。

3、 ng-model 与 input 值的问题
例如     input type="text" ng-model="querystr"
ng-model绑定到$scope.querystr 时,model会根据 text输入自动变化,但在controller中将
$scope.querystr=''时 ,text input的值不会产生变化。
并且在使用ng-model时,无法使用
angular.element(document).find(selector).val("some value");方式进行赋值。
解决方法是在controller 中,设置一个结构,如
$scope.queryMode ={querystr:''};
在input 中绑定   ng-model = "queryModel.querystr"
则controller中重设     $scope.queryMode.querystr = '';
绑定生效,input 清空。

4、cordova插件 ,在ripple中弹出错误窗口
如果安装cordova插件,如keyboard,statusbar 等, 会在ripple中抛各种错,并且每次加载会弹出窗口,让你写JSON回调, 这个是ripple的BUG,不支持自定义插件, 去掉弹窗的办法是在app.js上方,即定义angular.module()的上方

var annoyingDialog = parent.document.getElementByIdx_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x('exec-dialog');
上句中的x_x 去掉,新浪自动添加的。
if (annoyingDialog) annoyingDialog.outerHTML = "";
弹窗将不再出现,但输出窗口中的ripple.js中的错误仍会,你可以过滤,也可以不管。

5、使用极光推送,按照github上的说明文档,加入插件后总是无法编译,查看
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值