동일한 기능 범위에서 정의 및 요구 사항을 모두 사용할 수 있는지 알고 싶습니다. 일반적으로 요구 또는 정의 중 하나입니다, 어떻게 동일한 범위에서 둘 다합니까?RequireJS - 동일한 기능 범위에서 정의 및 요구 모두 사용
define(["my/cart", "my/inventory"],
function(cart, inventory) {
//Define foo/title object in here.
}
);
require(["some/module", "a.js", "b.js"], function(someModule) {
//This function will be called when all the dependencies
//listed above are loaded. Note that this function could
//be called before the page is loaded.
//This callback is optional.
});
보통 '정의'를 명시 적으로 호출하지 않습니다. 'define'은 보통 그 모듈에 대한'require' 호출의 결과로서 실행됩니다. 따라서 당신은 코드 내에서 ([ "foo/title"])'을 요구할 것이고, 이것은 모듈을로드/정의하게 할 것이다. –