Skip to main content
版本:v3

getCurrentPage

API_LEVEL 2.0 开始支持,API 兼容性请参考 API_LEVEL

获取 page 实例对象。

类型

function getCurrentPage(): Result

参数

Result

属性类型说明API_LEVEL
_optionsOptionspage 实例属性2.0

Options

属性类型必填默认值说明API_LEVEL
stateobject-page 实例上的挂载的数据对象2.0

代码示例

page.js
Page({
state: {
text: 'Hello Zepp OS',
},
onInit() {
console.log('onInit')
},
build() {
console.log('build')
console.log(this.state.text)
},
})

const page = getCurrentPage()
console.log(page._options.state.text)