简体   繁体   English

如何在页面WinJS之间传递变量?

[英]How to pass a variable between pages WinJS?

I'm trying to pass two variables from one page to the next. 我试图将两个变量从一个页面传递到下一个页面。 How would I go about doing this? 我该怎么做呢?

Put this code in first page: 将此代码放在第一页:

WinJS.Navigation.navigate("/pages/secondpage.html", yourvalue);

Then in second page to retrive the data use: 然后在第二页中检索数据使用情况:

ready: function (element, options) {
    //your data yourvalue is inside options parametr 
}

Very good example about navigation 关于导航的非常好的例子

WinJS navigation example WinJS导航示例

WinJS navigation example 2 WinJS导航示例2

只想包括一个传递多个值的例子,正如诺伯特在评论中回答的那样。

WinJS.Navigation.navigate("/pages/page2/page2.html", {value1:"hello",value2:"world"}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM