Weex Variable

Weex instance variable

Each Weex page has a separate weex variable, which exists in the JS context. They hold a single instance or method of the current Weex page.


This variable contains all the environment information for the current Weex page, including not only:

  • BundleUrl: string: The URL of the JS bundle.
  • Env: Object: environment object.
  • WeexVersion: string: Weex sdk version.
  • AppName: string: application name.
  • AppVersion: string: app version.
  • Platform: string: platform information, that is ‘iOS’, ‘android’ or ‘Web’.
  • OsVersion: string: system version.
  • DeviceModel: string: device model (native application only).
  • DeviceWidth: number: device width
  • DeviceHeight: number: device height. In Weex, the default width of viewport is 750px, thus you can obtain the height of screen by height = 750/deviceWidth*deviceHeight if the width of viewport remains its default value.

weex.requireModule(module: string): Object

Get all the methods of a native module, such as:

  <div><text>Hello World</text></div>
  var modal = weex.requireModule('modal')
    message: 'I am a toast.',
    duration: 3

weex.document: Document

Returns the document object of the current Weex page.