1***@163.com
1***@163.com
  • 发布:2016-11-28 16:33
  • 更新:2016-11-28 18:14
  • 阅读:1119

标签的style为什么在安卓真机上只能得到键值对的key 却得不到value

分类:MUI

代码
var homescroll = mui("#homehh")[0];
console.log(JSON.stringify(homescroll.style))

安卓真机调试console.log 得到的数据 "top":"","touchAction":"","transform":"","transformOrigin":"","transformStyle":"","transition":"","transitionDelay":"","transitionDuration":"","transitionProperty":"","
浏览器console.log 得到的数据
"top":"","touchAction":"","transform":"translate3d(0px, -362px, 0px) translateZ(0px)","transformOrigin":"","transformStyle":"","transition":"","transitionDelay":"","transitionDuration":"0ms","transitionProperty":"","

transform":"translate3d(0px, -362px, 0px) 浏览器这里明明是有值的
求解

2016-11-28 16:33 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

element.style读取的是内联的css的内容。

获取元素css的值,可以用如下方法。

var getStyles = function(element, property) {  
    var styles = element.ownerDocument.defaultView.getComputedStyle(element, null);  
    if (property) {  
        return styles.getPropertyValue(property) || styles[property];  
    }  
    return styles;  
};  
  • 1***@163.com (作者)

    谢谢 再请问一下property应该怎么填

    2016-11-29 10:19

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