Skip to content
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

define和dom文档加载 #883

Closed
hguankei opened this issue Aug 9, 2013 · 4 comments
Closed

define和dom文档加载 #883

hguankei opened this issue Aug 9, 2013 · 4 comments

Comments

@hguankei
Copy link

hguankei commented Aug 9, 2013

define(function(require){
var $ = require('jquery');
$(function{
//代码
})
})

请教模块文件还需要$(function(){})这个么

@lichunqiang
Copy link

#260 #326 看看这两个issue

@hguankei
Copy link
Author

hguankei commented Aug 9, 2013

@lichunqiang 这两个讲的是use的方法,那独立文件里面的define也是同理是吧?
还有seajsnode这个快速获取自身路径不是很明白?

@lifesinger
Copy link
Member

@hguankei dom ready 和 define 没必然关系。一般不推荐写 dom ready 了,只要保证里面的代码操作的 dom 在操作时已经 ok

用 seajs 异步后,只有很少的情况需要放在 dom ready 里,比如无法保障 dom ok 时。

@lichunqiang
Copy link

// Recommend to add `seajsnode` id for the `sea.js` script element
var loaderScript = doc.getElementById("seajsnode") ||  scripts[scripts.length - 1]

这是源码里面的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants