Runic
Runic
  • 发布:2016-08-29 15:58
  • 更新:2017-11-27 20:49
  • 阅读:3848

【报Bug】mui.js v3.3.0 Transparent 透明导航栏 取色错误

分类:MUI
mui

问题:mui.js
版本:v3.3.0
Transparent 透明导航栏 取色错误、正则逻辑存在问题,传入小数取值为空。

mui.js:7732 Uncaught Error: 元素背景颜色必须为RGBA
Transparent @ mui.js:7732
(anonymous function) @ mui.js:7767
(anonymous function) @ mui.js:443
each @ mui.js:442
$.fn.transparent @ mui.js:7752
(anonymous function) @ mui.js:7774
(anonymous function) @ mui.js:205

2016-08-29 15:58 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

已确认bug,下个版本修复。

  • 9***@qq.com

    请问bug已经修改了吗?

    2016-10-09 18:19

  • Trust

    回复 9***@qq.com:已修复

    2016-10-09 20:16

  • Runic (作者)

    这个还是存在 BUG,我尝试设置 rgba(0,0,0,0.9) 时, 0.9 取值 会浮点数溢出,变成 0.901961 这应该是 js 比较出名的BUG、你们正则 还得优化。

    2017-01-14 15:33

  • Runic (作者)

    调用 mui.getStyles 取值得到的内容。 "rgba(0, 0, 0, 0.901961)" 正则只匹配了 3位小数。

    2017-01-14 15:34

Runic

Runic (作者)

不给力啊,看了下最新版的,Transparent 还是 不支持取带透明的 导航栏

Feista

Feista

不给力呀,这问题还是没解决

3***@qq.com

3***@qq.com

把原来的var f = e(mui.getStyles(this.element, "backgroundColor"));改为
var f = e(mui.getStyles(this.element, "background-color"));就可以了。
另外 样式中 background-color: rgba(30, 150, 202, 0.9); rgba中的a要小于1感觉。。。

1***@qq.com

1***@qq.com

版本:Mui v3.7.0
同样出现了这样的问题,我看了下mui.js的源码

// 第8007行,这行代码中,mui.getStyles(this.element, 'backgroundColor')的值是rgb类型的,不是rgba  
var color = getColor(mui.getStyles(this.element, 'backgroundColor'));  

// 更改如下:  
// 第7961行,上面调用getColor()函数执行到这里,  
// 这是正则匹配rgba,由于传过来的是rgb,所以不可能匹配到  
var rgbaRegex = /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/;  

// 更改如下  
var rgbaRegex = /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/;  
var rgbRegex = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/;  

var getColor = function(colorStr) {  
        var matches = colorStr.match(rgbaRegex);  
        var matches1 = colorStr.match(rgbRegex);  
        console.log(matches1)  
        if (matches && matches.length === 5) {  
            return [  
                matches[1],  
                matches[2],  
                matches[3],  
                matches[4]  
            ];  
        } else if(matches1 && matches1.length === 4) {  
                return [  
                    matches1[1],  
                matches1[2],  
                matches1[3],  
                1.0  
                ];  
        }  
        return [];  
    };

我在这个函数中添加了一个判断,如果是rgb时,还是返回rgb的颜色,并设置默认opacity为1

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