柒澧
柒澧
  • 发布:2016-01-26 11:51
  • 更新:2018-12-15 15:42
  • 阅读:2021

INVALID_CHARACTER_ERR: DOM Exception 5 at js/mui.min.js:8

分类:HBuilder

做个一个页面 数据都返回了 但是提示Uncaught Error:INVALID_CHARACTER_ERR: DOM Exception 5 at js/mui.min.js:8 界面显示的数据不全 只显示一屏 并且不能上拉滑动

2016-01-26 11:51 负责人:无 分享
已邀请:
notbug

notbug

大兄弟,我也遇到这个问题。在网页上显示没有一丁点毛病,拿去安卓上测试就挂了,心凉了半截,看着这张帖子时两年半前的,无人解决,在填坑这条路上,我们是孤独的。进了官方群,大半都是跟我一样搞拿来主义的。自己用未压缩版的mui.js 拿去模拟器上测试,看了源码 发现问题就出在 第5500行设置属性那 官方可能考虑用URL作唯一识别 但是 似乎里面存在一些特殊字符 如?&的时候就会抛DOM Execption

$.fn.pullRefresh_native = function(options) {  
            var self;  
            if (this.length === 0) {  
                self = document.createElement('div');  
                self.className = 'mui-content';  
                document.body.appendChild(self);  
            } else {  
                self = this[0];  
            }  
            var args = options;  
            //一个父需要支持多个子下拉刷新  
            options = options || {}  
            if (typeof options === 'string') {  
                options = $.parseJSON(options);  
            };  
            !options.webviewId && (options.webviewId = (plus.webview.currentWebview().id || plus.webview.currentWebview().getURL()));  
            var pullRefreshApi = null;  
            var attrWebviewId = options.webviewId && options.webviewId.replace(/\//g, "_"); //替换所有"/"  
            var id = self.getAttribute('data-pullrefresh-' + attrWebviewId);  
            if (!id && typeof args === 'undefined') {  
                return false;  
            }  
            if (!id) { //避免重复初始化5+ pullrefresh  
                id = ++$.uuid;  
                self.setAttribute('data-pullrefresh-' + attrWebviewId, id);  
                document.body.classList.add(CLASS_PLUS_PULLREFRESH);  
                $.data[id] = pullRefreshApi = new PlusPullRefresh(self, options);  
            } else {  
                pullRefreshApi = $.data[id];  
            }  
            if (options.down && options.down.auto) { //如果设置了auto,则自动下拉一次  
                //pullRefreshApi._pulldownLoading(); //parent webview  
                pullRefreshApi.beginPulldown();  
            } else if (options.up && options.up.auto) { //如果设置了auto,则自动上拉一次  
                pullRefreshApi.beginPullup();  
            }  
            return pullRefreshApi;  
        };

好在官方留了拓展 允许自定义options.webviewId 不过我找不到传入参数的格式 追了好几层都绕晕了,索性来点简单粗暴的 直接
plus.webview.currentWebview().id = 'xxxx';
xxx换成你下拉容器的id
希望下一回有人能顺道绕坑

  • 秋天无风

    兄弟,你比官方靠谱多了。

    这个是正解。我就是用了?=xxx的形式 传参,然后用url作为webviewid。造成这种错误的,更改webviewid,就没这个了。感谢。

    2019-04-16 10:17

k***@qq.com

k***@qq.com

感谢上面大兄弟~
解决方法是:不能通过?=xxx的形式 传参

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