我有一个非常简单的应用程序。我开始使用VS2015中的WinJS App(通用Windows)模板。我有一个拆分视图,在拆分视图内容部分我有一个菜单。单击控制按钮时会出现菜单,但不能选择任何选项。
<div data-win-control="WinJS.UI.SplitView" data-win-options="{closedDisplayMode: 'overlay',panePlacement:'left'}">
<div class="win-splitview-pane">
</div>
<div class="win-splitview-content">
<button id="selectionButton">Selection</button>
<div id="selectionMenu" data-win-control="WinJS.UI.Menu">
<button data-win-options="{label:'Forward',type:'toggle'}" data-win-control="WinJS.UI.MenuCommand"></button>
<button data-win-options="{label:'Reply',type:'toggle'}" data-win-control="WinJS.UI.MenuCommand"></button>
<button data-win-options="{label:'Reply All',type:'toggle'}" data-win-control="WinJS.UI.MenuCommand"></button>
</div>
</div>
</div>
此代码的JavaScript代码很简单(在initSelection
部分调用了app.onactivated
):
function initSelection() {
document.getElementById("selectionButton").addEventListener("click", showFlyout, false);
}
function showFlyout() {
document.getElementById("selectionMenu").winControl.show(document.getElementById("selectionButton"), "bottom", "left");
}
这甚至可能吗?怎么样?提前谢谢你。
答案 0 :(得分:0)
看起来您必须将选择菜单放在拆分视图内容部分之外,如下所示:
<div data-win-control="WinJS.UI.SplitView" data-win-options="{closedDisplayMode: 'overlay',panePlacement:'left'}">
<div class="win-splitview-pane">
</div>
<div class="win-splitview-content">
<button id="selectionButton">Selection</button>
</div>
</div>
<div class="win-interactive" id="selectionMenu" data-win-control="WinJS.UI.Menu">
<button class="win-interactive" data-win-options="{label:'Forward'}" data-win-control="WinJS.UI.MenuCommand"></button>
<button class="win-interactive" data-win-options="{label:'Reply'}" data-win-control="WinJS.UI.MenuCommand"></button>
<button class="win-interactive" data-win-options="{label:'Reply All'}" data-win-control="WinJS.UI.MenuCommand"></button>
</div>
这是WinJS团队的建议:https://github.com/winjs/winjs/issues/1553#issuecomment-159416488
一旦你这样做,它就会起作用。