Windows 10 Universal App - WinJS SplitViewCommand

时间:2015-12-10 21:10:24

标签: windows-10 win-universal-app winjs

我正在尝试在Windows Universal App中使用WinJS SplitView。 我创建了新项目并添加了此示例中的代码:http://try.buildwinjs.com/

所以我的HTML看起来像这样:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>App1</title>

    <!-- WinJS references -->
    <link href="WinJS/css/ui-dark.css" rel="stylesheet" />
    <script src="WinJS/js/base.js"></script>
    <script src="WinJS/js/ui.js"></script>

    <!-- App1 references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>
</head>
<body class="win-type-body">
    <div id="app">
        <div class="splitView" data-win-control="WinJS.UI.SplitView">
            <!-- Pane area -->
            <div>
                <div class="header">
                    <button class="win-splitviewpanetoggle"
                            data-win-control="WinJS.UI.SplitViewPaneToggle"
                            data-win-options="{ splitView: select('.splitView') }"></button>
                    <div class="title"><h3 class="win-h3">SplitView Pane Area</h3></div>
                </div>

                <div class="nav-commands">
                    <div data-win-control="WinJS.UI.SplitViewCommand" data-win-options="{ label: 'Home', icon: 'home'}"></div>
                    <div data-win-control="WinJS.UI.SplitViewCommand" data-win-options="{ label: 'Favorite', icon: 'favorite'}"></div>
                    <div data-win-control="WinJS.UI.SplitViewCommand" data-win-options="{ label: 'Settings', icon: 'settings'}"></div>
                </div>
            </div>

            <!-- Content area -->
            <div class="contenttext"><h2 class="win-h2">SplitView Content Area</h2> </div>
        </div>
    </div>

</body>
</html>

运行应用程序时几乎一切正常。唯一的问题是菜单项(SplitViewCommand)。它们不会显示。

检查HTML WinJS.UI.SplitView并正确处理WinJS.UI.SplitViewPaneToggle但未处理WinJS.UI.SplitViewCommand时。看起来app似乎不知道WinJS.UI.SplitViewCommand是什么。

1 个答案:

答案 0 :(得分:0)

检查base.js文件中的WinJS库版本。 WinJS.UI.SplitView在WinJS 4.0及更高版本中可用,但对WinJS.UI.SplitViewCommand对象的支持从WinJS 4.2开始。