Skip to content

Conversation

@Hanks10100
Copy link
Contributor

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Other information:

weex.supports

weex.supports is used to detect whether a feature is supported in the current environment.

API

weex.supports(condition: String): Boolean | Null

Parameter

  • a formatted string: @{type}/{name}.

The type must be "component" or "module", the name can be tag name, module name or the method name in a specific module.

Return Value

  • if supported, returns true.
  • if unsupported, returns false.
  • if unclear, returns null.

Examples

// Detects whether the specific component is supported
weex.supports('@component/slider') // true
weex.supports('@component/my-tab') // false

// Detects whether the specific module is supported
weex.supports('@module/stream')  // true
weex.supports('@module/abcdef')  // false

// Detects whether the method in specific module is supported
weex.supports('@module/dom.getComponentRect') // true
weex.supports('@module/navigator.jumpToPage') // false

// invalid input
weex.supports('div') // null
weex.supports('module/*') // null
weex.supports('@stream/fetch') // null
weex.supports('getComponentRect') // null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants