JavaScript运行时错误:'$'未定义 [英] JavaScript runtime error: '$' is undefined
问题描述
所以经典的问题,但有一个可怕的时间,找到实际的原因。通常当我看到这个错误,因为jQuery引用是在需要它的代码,或后面的jQuery链接,或jQuery冲突,等...到目前为止没有一个似乎是这种情况。不幸的是寻找这个问题的解决方案导致我后这样的案件后。我相信我的问题在这里是同样简单,但超过一个小时的狩猎,仍然没有运气...
So classic problem, but having a horrible time on finding the actual cause. Typically when I see this error it's because the jQuery reference is after code requiring it, or back jQuery link, or jQuery conflict, etc... so far none of those appear to be the case. Unfortunately seeking out the solution to this problem has lead me to post after post of such cases. I'm sure my problem here is equally as simple, but over an hour of hunting, still no luck...
编辑:附加信息...
解决方案文件(我已经重新创建多次试图找出这是一个JavaScript Windows商店空白应用程序模板,我在Visual Studio中这样做唯一的参考文件是Windows库的JavaScript 1.0,我试过
Additional information... The solution file (which I've recreated multiple times trying to figure this out. Is a JavaScript Windows Store Blank App template and I'm doing this in Visual studio. The only references files is Windows Library for javascript 1.0, I have tried deleting this to test as well.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>HTML5 Canvas Template</title>
<style>
/* styles here */
</style>
</head>
<body>
<canvas id="myCanvas" width="500" height="500">
<p>Canvas not supported.</p>
</canvas>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var canvas = $("#myCanvas").get(0);
var context = canvas.getContext("2d");
function renderContent()
{
// we'll do our drawing here...
}
renderContent();
});
</script>
</body>
</html>
推荐答案
JQuery
引用的网址不正确
It's states that JQuery
referred URL is not correct
尝试:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
这篇关于JavaScript运行时错误:'$'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!