这里是我的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本身的问题。发布一个小样本,我们可能会提供帮助 –