加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – PhoneGap 2.8.0使用angular-mobile-nav提高“无方

发布时间:2020-12-17 17:30:55 所属栏目:安全 来源:网络整理
导读:我在使用Ripple Emulator的Cordova 2.8 Android项目的最初页面加载时遇到了angular-mobile-nav的问题.我得到的错误是: TypeError: Object #Object has no method 'overrideBackbutton' at module.exports.exec (chrome-extension://geelfhphabnejjhdalkjhgi
我在使用Ripple Emulator的Cordova 2.8 Android项目的最初页面加载时遇到了angular-mobile-nav的问题.我得到的错误是:

TypeError: Object #<Object> has no method 'overrideBackbutton'
    at module.exports.exec (chrome-extension://geelfhphabnejjhdalkjhgipohgpdnoc/ripple.js:40:22917)
    at backButtonChannel.onHasSubscribersChange (http://localhost:8076/cordova.js:1145:13)
    at Channel.subscribe (http://localhost:8076/cordova.js:667:49)
    at HTMLDocument.document.addEventListener (http://localhost:8076/cordova.js:132:34)
    at null.<anonymous> (http://localhost:8076/components/mobile-nav/mobile-nav.js:11:14)
    at Channel.fire (http://localhost:8076/cordova.js:709:23)
    at http://localhost:8076/cordova.js:232:47

基本上,它是由mobile-nav.js第11行引起的:
document.addEventListener(“backbutton”,function(){

而来自第1145行的cordova.js电话引发的错误:
exec(null,null,“App”,“overrideBackbutton”,[this.numHandlers == 1]);

这是一个可以复制的问题吗?任何帮助将不胜感激.

解决方法

我在第一次使用Ripple和Phonegap 2.5.0时遇到过这种情况.正如你所指出的,在Android的cordova-2.8.0.js的第1145行,它假定在Android平台上运行,因此调用本机函数App.overrideBackbutton(),其中Ripple没有存根.

因为它只是在附加/分离第一个处理程序时调用它,所以我通过欺骗Ripple认为已经存在多个处理程序来解决这个问题:

<html>
    <head>
        <script type="text/javascript" charset="utf-8" src="cordova-2.8.0.js"></script>
        <script type="text/javascript" charset="utf-8" src="jquery-1.7.1.min.js"></script>

        <script type="text/javascript">
        _IS_RIPPLE_EMULATOR = $('#tinyhippos-injected').length > 0;

        function deviceready() {
            // Make ripple think that a back button handler has already been attached
            if(_IS_RIPPLE_EMULATOR) cordova.addDocumentEventHandler('backbutton'); 

            document.addEventListener("backbutton",function(){
                alert("Pressed back");
            });

        }
        document.addEventListener("deviceready",deviceready,true);        
        </script>
    </head>
    <body></body>
</html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读