Skip to content

PassValuesBetweenPages

hp-sam edited this page Dec 9, 2014 · 1 revision

传递参数给下一个页面

如何传递

旧代码实现push下一个页面

apps.pushPage("pageid")
apps.push("appid", "pageid")
apps.switchPage("pageid")
apps.switch("appid")

新代码实现

--- apps.pushPage(context)
apps.pushPage({
    pageId = "somepageid",
    my_parameters = xxx
})
--- apps.push(context)
apps.push({
    appId = "appid",
    pageId = "pageid",
    my_parameters = xxx
})

--- apps.switchPage(context)
apps.switchPage({
    pageId = "pageid",
    my_parameters = xxx
})

--- apps.switch(context)
apps.switch({
    appId = "appid",
    my_parameters = xxx
})

新代码接收

--- 新页面
function onCreated(context)
    -- context: {appId = "appid", my_parameters = xxx}
    local my_parameters = context.my_parameters
    ...
end

Clone this wiki locally