widget.getProperty(key)
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Get the UI widget properties, use widget.getProperty(prop.MORE, {})
to get all the properties of the widget.
Type
(key: any) => result
Parameters
Parameter | Description | Type |
---|---|---|
key | The value of property. | any |
Code example
import { createWidget, widget, prop } from '@zos/ui'
const img_bkg = createWidget(widget.IMG)
const img_prop = img_bkg.getProperty(prop.MORE, {})
const { angle, w, h } = img_prop
const imgHeight = img_bkg.getProperty(prop.H)
caution
At this stage, some widgets do not support property acquisition, it is recommended to try to get first, if you can not get the value, you can refer to the following code snippet, manually maintain a variable in the current page to record the corresponding property changes
import { createWidget, widget } from '@zos/ui'
Page({
state: {
buttonY: 0
},
build() {
this.state.buttonY = 300
createWidget(widget.BUTTON, {
y: this.state.buttonY,
// ...
})
showToast({
text: this.state.buttonY
})
}
})