0
我嘗試使用HTML5 與WP8.1添加appbar,我使用這個鏈接來指導我 Quickstart: Adding an app bar with commands (HTML)添加在WP8.1 HTML5的應用欄
但它表明我這個問題(錯誤),沒有錯誤,因爲你看到圖像。
我嘗試使用HTML5 與WP8.1添加appbar,我使用這個鏈接來指導我 Quickstart: Adding an app bar with commands (HTML)添加在WP8.1 HTML5的應用欄
但它表明我這個問題(錯誤),沒有錯誤,因爲你看到圖像。
這是我的解決方案
頁default.html中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CheckCnxInternet</title>
<!-- WinJS references -->
<!-- At runtime, ui-themed.css resolves to ui-themed.light.css or ui-themed.dark.css
based on the user’s theme setting. This is part of the MRT resource loading functionality. -->
<link href="/css/ui-themed.css" rel="stylesheet" />
<script src="//Microsoft.Phone.WinJS.2.1/js/base.js"></script>
<script src="//Microsoft.Phone.WinJS.2.1/js/ui.js"></script>
<!-- CheckCnxInternet references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
<script src="/js/Appbar.js"></script>
</head>
<body class="phone">
<!-- Create AppBar -->
<!-- BEGINTEMPLATE: Template code for an AppBar -->
<div id="createAppBar" data-win-control="WinJS.UI.AppBar" data-win-options="{closedDisplayMode:'minimal'}">
<button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdAdd',label:'Add',icon:'add',tooltip:'Add item'}"></button>
<button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdRemove',label:'Remove',icon:'remove',tooltip:'Remove item'}"></button>
<button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdEdit',label:'Edit',icon:'edit',tooltip:'Edit item'}"></button>
<button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdCamera',label:'Camera',icon:'camera',section:'selection',tooltip:'Take a picture'}"></button>
</div>
<!-- ENDTEMPLATE -->
</body>
</html>
爲default.js讓它沒有modifcation, 沒有Appbar.js
的代碼(function() {
"use strict";
var appBar;
var cx = new Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile();
var page = WinJS.UI.Pages.define("default.html", {
ready: function (element, options) {
appBar = document.getElementById("createAppBar").winControl;
appBar.getCommandById("cmdAdd").addEventListener("click", doClickAdd, false);
appBar.getCommandById("cmdRemove").addEventListener("click", doClickRemove, false);
appBar.getCommandById("cmdEdit").addEventListener("click", doClickEdit, false);
appBar.getCommandById("cmdCamera").addEventListener("click", doClickCamera, false);
}
});
// Command button functions
function doClickAdd() {
WinJS.log && WinJS.log("Add button pressed", "sample", "status");
}
function doClickRemove() {
WinJS.log && WinJS.log("Remove button pressed", "sample", "status");
}
function doClickEdit() {
WinJS.log && WinJS.log("Edit button pressed", "sample", "status");
}
function doClickCamera() {
WinJS.log && WinJS.log("Camera button pressed", "sample", "status");
}
})();
我希望它有幫助:)