【问题标题】:winjs: how to navigate to html page using winjs libraries.?winjs:如何使用 winjs 库导航到 html 页面。?
【发布时间】:2013-08-19 14:01:26
【问题描述】:

我在HTML5/JAVASCRIPT的平台上开发windows store app,并安装了SPLIT APP的模板。

我想显示一个HTML 页面。如果我使用HTML Hyperlink 属性显示,则 html 页面会显示在完整的窗口中,我无法从那里返回。我唯一的方法是需要重新初始化应用程序。

所以,我从这里http://msdn.microsoft.com/en-us/library/windows/apps/hh770584.aspx 浏览了所有winjs 库及其函数

来自我使用的那个链接;

var hello = WinJS.UI.Pages.get('/def/f1.html');

如果我使用这些库中的解释; f1.html 没有显示在应用程序中,而是显示了下图。

【问题讨论】:

    标签: javascript windows-store-apps winjs


    【解决方案1】:

    对于windows store App的单页导航,我们可以试试下面的代码片段。 这里我在Project中添加了一个页面控件,从app bar按钮click导航到这个页面。所以我们需要在default.html中添加app bar中的按钮

    <div id="appbar" data-win-control="WinJS.UI.AppBar">
            <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmd', label:'Command', icon:'placeholder'}" type="button"></button>
               <button 
                data-win-control="WinJS.UI.AppBarCommand" 
                data-win-options="{id:'cmdMove',label:'Remove',icon:'delete',
                    section:'global',tooltip:'move item'}">
            </button>
        </div>
    

    然后在default.js中

    document.getElementById("cmdMove")
                  .addEventListener("click", Move, false);
    
     function Move() {
    
            WinJS.Navigation.navigate("/pages/test.html");
    
        }
    

    它将导航到 test.html ,当我们到达 test.html 时,它有一个返回按钮可以返回上一页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多