window.getComputedStyle(elem,null).getPropertyValue(“style”)和window.getComputedStyle(elem,null).style有什么区别
window.getComputedStyle(elem,null).getPropertyValue(“style”)和window.getComputedStyle(elem,null).style有什么区别
1 回答862 阅读✓ 已解决
1 回答1.1k 阅读
2 回答780 阅读
2 回答622 阅读
2 回答610 阅读
1 回答685 阅读
2 回答531 阅读
window.getComputedStyle(elem,null)返回`CSSStyleDeclaration对象这个对象有
getPropertyValue`方法获取对应css属性的值例如
getPropertyValue('color');//获取字体颜色子CSSStyleDeclaration是没有style属性的
你是不是想问
window.getComputedStyle(elem,null).getPropertyValue(“color”)和window.getComputedStyle(elem,null).color有什么区别
有区别,属性值是不同的访问方式
在访问例如background-color类似格式的css属性时
`window.getComputedStyle(elem,null).background-color就不可以了,需要使用window.getComputedStyle(elem,null).backgroundColor访问window.getComputedStyle(elem,null).getPropertyValue(“background-color”)是可以的