這裏是我的default.html和文件支持jQuery的
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>app1</title>
<!-- WinJS references -->
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
<!-- app1 references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
<script src="/js/jquery.js"></script>
</head>
<body>
<button id="buttonYouWantToClick">Button</button>
<div id="result"></div>
<p>Content goes here</p>
</body>
</html>
和default.js文件。我在app.start()
函數之前放jquery
代碼。
...
$(document).ready(function() {
$('#buttonYouWantToClick').click(function() {
$('#result').html('jQuery works!');
});
});
app.start();
})();
我也試過之後args.setPromise(WinJS.UI.processAll());
(function() {
"use strict";
WinJS.Binding.optimizeBindingReferences = true;
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
// TODO: This application has been newly launched. Initialize
// your application here.
} else {
// TODO: This application has been reactivated from suspension.
// Restore application state here.
}
args.setPromise(WinJS.UI.processAll());
$(document).ready(function() {
$('#buttonYouWantToClick').click(function() {
$('#result').html('jQuery works!');
});
});
}
};
app.oncheckpoint = function (args) {
// TODO: This application is about to be suspended. Save any state
// that needs to persist across suspensions here. You might use the
// WinJS.Application.sessionState object, which is automatically
// saved and restored across suspension. If you need to complete an
// asynchronous operation before your application is suspended, call
// args.setPromise().
};
app.start();
})();
在兩個案例不起作用。我得到同樣的錯誤
SCRIPT5009:在MS-APPX線38,列5未處理的異常://a8fcf58a-3cda-4e8c-ae43-733030e738e2/js/default.js 0x800a1391 - JavaScript的運行時錯誤:「$ '未定義 文件:default.js,行:38,列:5 HTML1300:導航發生。 文件:default.html中
APPHOST9623:應用程序無法解析MS-APPX://a8fcf58a-3cda-4e8c-ae43-733030e738e2/js/jquery.js因爲這個錯誤的:RESOURCE_NOT_FOUND。 Visual Studio當前未附加到支持腳本診斷的腳本調試目標。
在此先感謝。
Thanks.But我下載了所有的jQuery庫,並嘗試每一個,並再次得到了同樣的錯誤0x800a1391 - JavaScript運行時錯誤:'$'未定義。 – Karlen
甚至在發佈公告之前@Johannes指出,jQuery當然可以在您描述的錯誤之外運行。該錯誤通常是因爲jquery庫沒有正確加載到您的JavaScript文件中,而不是因爲jQuery本身的問題。發佈一個小樣本,我們可能會提供幫助 –