这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

parse() 方法在 CSSStyleValue interface sets a specific CSS property to the specified values and returns the first value as a CSSStyleValue 对象。

句法

CSSStyleValue.parse(property, cssText)
					

参数

property

A CSS property to set.

cssText

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.
工作草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改:
  1. CSSStyleValue
  2. 方法
    1. parse()
    2. parseAll()