这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
parse()
方法在
CSSStyleValue
interface sets a specific CSS property to the specified values and returns the first value as a
CSSStyleValue
对象。
CSSStyleValue.parse(property, cssText)
A CSS property to set.
A comma-separated string containing one or more values to apply to the provided property.
A
CSSStyleValue
object containing the first supplied value.
The code below parses a set of declarations for the
transform
property. The second code block shows the structure of the returned object as it would be rendered in a developer tools console.
const css = CSSStyleValue.parse(
'transform', 'translate3d(10px,10px,0) scale(0.5)');
CSSTransformValue {0: CSSTranslate, 1: CSSScale, length: 2, is2D: false}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Typed OM Level 1
The definition of 'parse()' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
parse
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
完整支持
不支持
实验。期望将来行为有所改变。
CSSStyleValue
parse()
parseAll()