Application Instance
The WeDa frontend application instance can be accessed via $w.app
, and $app
can also be used as a shortcut reference.
Properties
id: string
Application id
label: string
Application Name
version: string
The application version is empty in the Preview & Enterprise Workspace.
mpAppId: string
Mini Program appid, empty if not on the Mini Program client
mpAppName: string
Mini Program Name, empty if not on the Mini Program client
dataset: AppDataset
Global Data Object
common: Object
Global low-code common methods, accessed via $w.app.common.<common filename>.<exported method>
, for example, $w.app.common.console.log('something')
Methods
$w.app.setState
$w.app.setState(data: object): void
Feature Description
Setting the value of $w.app.dataset.state
uses the key
of the passed object
as a path and, in the order of the keys, sets the value at the corresponding path in $w.app.dataset.state
to the value
of the object. Properties that do not exist will be created, and other properties will not be modified.
Input Parameters
Name | Type | Description |
---|---|---|
data | object | An object with the path as the key and the new value as the value |
An Object is represented in the form of key: value, which changes the value corresponding to the key in $w.page.dataset.state to the value.
Example
console.log($w.app.dataset.state.data);
// undefined
$w.app.setState({ "data": { test: 'data' } })
console.log($w.app.dataset.state.data);
/**
* {
* test: "data"
* }
* /
AppDataset
Name | Type | Description |
---|---|---|
state | object | A global variable in WeDa applications, accessed and assigned via $w.app.dataset.state.xxx |