我正在为 AMD 尝试使用 requirejs 和 jquery 的简单演示。以下是我的文件夹结构结构:
├── index.html
└── js
├── lib
│ ├── jquery.js
│ └── require.js
└── main.js
在我的 index.html 文件中,我有以下内容:
<head>
<script data-main="js/main" src="js/lib/require.js"></script>
</head>
<body>
<div id="hello"> </div>
</body>
我的 main.js 文件如下所示:
define(['lib/jquery'], function ($) {
$("#hello").html("Wow this works!");
});
但是当我这样做时,我得到一个错误:Uncaught TypeError: undefined is not a function
在 main.js 第 3 行。
怎么了?我看不懂?