Drex
Drex
  • 发布:2015-06-03 15:49
  • 更新:2015-06-12 15:34
  • 阅读:2660

Object xxx.html has no method 'evalJS'

分类:HTML5+

主页面加载子文件xxx.html,主页面的按钮点击弹出子页面层,代码按照Hello mui写的,但是报错Object xxx.html has no method 'evalJS'

2015-06-03 15:49 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

是子页面webview.evalJS('mui("#popover").popover("toggle");');

Drex

Drex (作者)

用的就是这个方法,提示报错
子夜面需要写方法吗?

Drex

Drex (作者)

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <title>信息</title>  
        <link href="../css/mui.css" rel="stylesheet" />  
        <link href="../css/style.css" rel="stylesheet" />  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav">  
            <a class="mui-icon mui-icon-left-nav mui-pull-left mui-action-back"></a>  
            <a href="#offSearch" class="mui-icon mui-icon-search mui-pull-right"></a>  
        </header>  
        <div class="mui-class-tabs mui-margin-top">  
            <ul class="mui-table-view-chevron">  
                <li class="mui-table-view-cell mui-collapse mui-col-xs-4"><a id="type" class="mui-navigate-right" href="#">类型</a>  
                </li>  
            </ul>  
        </div>  
        <script src="../js/mui.min.js"></script>  
        <script type="text/javascript" charset="utf-8">  
            mui.init();  
            var subpages = ['vrxxexxal.html', 'dstxxxxxudxxxio.html'];  
            var subpage_style = {  
                top: '90px',  
                bottom: '0px'  
            };  

             //创建子页面,首个选项卡页面显示,其它均隐藏;  
            mui.plusReady(function() {  
                var self = plus.webview.currentWebview();  
                for (var i = 0; i < 2; i++) {  
                    var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);  
                    if (i > 0) {  
                        sub.hide();  
                    }  
                    self.append(sub);  
                }  
            });  

             //当前激活选项  
            var activeTab = subpages[0];  

             //选项卡点击事件  
            mui('.mui-segmented-control').on('tap', 'a', function(e) {  
                var targetTab = this.getAttribute('href');  
                if (targetTab == activeTab) {  
                    return;  
                }  
                //显示目标选项卡  
                plus.webview.show(targetTab);  
                //隐藏当前;  
                plus.webview.hide(activeTab);  
                //更改当前活跃的选项卡  
                activeTab = targetTab;  
            });  

            //筛选条件  
            document.getElementById("type").addEventListener('tap', function(e) {  
                e.stopPropagation();  
                if(activeTab == null){  
                    activeTab = plus.webview.currentWebview().children()[1];  
                }  
                setTimeout(function() {  
                    activeTab.evalJS('mui("#topPopover").popover("toggle")');  
                }, 2000);  
            });  
        </script>  
    </body>  

</html>
  • DCloud_UNI_FXY

    你的activeTab是个字符串(webview id),不是webview,plus.webview.getWebviewById(activeTab).evalJS...

    2015-06-12 15:35

  • Drex (作者)

    好像是解决楼,谢谢大神!

    2015-06-12 15:41

  • Drex (作者)

    回复 DCloud_UNI_FXY:子页面向父页面传值能用这个函数吗?

    2015-06-15 14:49

  • DCloud_UNI_FXY

    回复 Drex:可以。执行js函数,拼写参数执行

    2015-06-15 14:55

  • Drex (作者)

    回复 DCloud_UNI_FXY:plus.webview.getWebviewById('center/pl.html').evalJS('document.getElementById("style").innerHTML = "+sssssssssssss+"');这样写对吗?

    2015-06-15 15:12

  • DCloud_UNI_FXY

    嗯。是这意思。但是需要注意单双引号的拼写

    2015-06-15 16:09

Drex

Drex (作者)

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <title>信息</title>  
        <link href="../css/mui.css" rel="stylesheet" />  
        <link href="../css/style.css" rel="stylesheet" />  
    </head>  

    <body>  
        <div id="pullrefresh" class="mui-content-padded mui-scroll-wrapper">  
            <div class="mui-scroll">  
                <ul id="real" class="mui-place-list">  
                    <div class="mui-pull">  
                        <div class="mui-pull-loading mui-icon mui-spinner"></div>  
                        <div class="mui-pull-caption">正在加载...</div>  
                    </div>  
                </ul>  
            </div>  
        </div>  
        <!--类型弹出菜单-->  
        <div id="typelist" class="mui-popover">  
            <div class="mui-popover-arrow"></div>  
            <div class="mui-scroll-wrapper">  
                <div class="mui-scroll">  
                    <ul id="type" class="mui-table-view mui-table-view-list">  
                    </ul>  
                </div>  
            </div>  
        </div>  
        <script src="../js/mui.min.js"></script>  
        <script type="text/javascript" charset="utf-8">  
            mui.init();  
        </script>  
    </body>  

</html>

该问题目前已经被锁定, 无法添加新回复