-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
能否增加一个类似require.js的data-main #49
Comments
我觉得你对 main指的是入口模块,用于app启动的。类似于C里的main函数。通常情况下一个应用总需要一个模块作为启动入口, 正确使用 <head>
<script data-main="main" src="js/require.js"></script>
</head> 假设你要配置config,正确姿势应该是: <head>
<script data-main="main" src="js/require.js"></script>
<script>
require.config({
});
</script>
</head> 不正确的姿势是:
|
确实是这样,但是随便举个例子而已。如果有data-main的话,我可以减少写一行入口模块的执行脚本 |
了解,有空的时候我实现下,看看体积具体增加了多少,再决定是否加入此特性。此issue先保持open状态 |
其实很早之前用require.js的第一思路是。 <script data-main="js/config" src="js/require.js"></script>
```javascript
// config.js
require.config({
paths: {
jquery:"lib/jquery.min"
}
});
```javascript
// 当前页面的js
require(['jquery'], function($){
console.log($)
});
然后直接就挂了。 |
挂是对的。因为页面上js执行时,你config.js还没回来,所以 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如题,在require.js里面data-main属性指向的文件这个文件会第一个被require.js加载。这样的话,在开发过程中就可以少一个script标签引入config文件。
The text was updated successfully, but these errors were encountered: