cakephp, 백본 및 requirejs로 개발 된 사이트가 있습니다.다른 파일의 경로 사용 요구
내 설정 파일에 자바 스크립트를 매핑하고이 파일에 jquery를 호출하면 정상적으로 작동합니다. 다른 파일에 jquery를 호출하면 jquery가로드되지 않은 것처럼 함수가 indefined라는 오류가 발생합니다. 내가 config.js
require.config({
baseUrl: "/site.com/js/",
paths: {
// Aliases for libraries, so that we can change versions from here
jquery: "libs/jquery/jquery-2.0.2.min",
handlebars: "libs/backbone/template/handlebars",
lodash: "libs/backbone/template/lodash.min",
backbone: "libs/backbone/backbone-1.0.0.min",
less:"libs/less/less-1.4.0-beta.min",
helper:"app/helper",
jquery_cookie:"libs/jquery/plugin/jquery.cookie",
text:"libs/require/text-2.0.7"
},
shim: {
"lodash": { exports: '_' },
"handlebars": { exports: 'Handlebars' },
"jquery": { exports: '$' },
"backbone": {
//These script dependencies should be loaded before loading
//backbone.js
deps: ["helper", "lodash", "jquery"],
//Once loaded, use the global "Backbone" as the
//module value.
exports: "Backbone"
},
"jquery_cookie": {
deps: ["jquery"]
//,exports:"$"
},
"less": {
exports:"less"
}
}
// This is appended to every module loading request, for cache invalidation purposes
// comment it on production
, urlArgs: "bust=" + (new Date()).getTime()
});
에이를 작성하고 검색하려면 default.ctp에 JQuery와에 전화를 이동하는 대신 경우
require.config({
baseUrl: "/site.com/js/",
paths: {
// Aliases for libraries, so that we can change versions from here
jquery: "libs/jquery/jquery-2.0.2.min",
handlebars: "libs/backbone/template/handlebars",
lodash: "libs/backbone/template/lodash.min",
backbone: "libs/backbone/backbone-1.0.0.min",
less:"libs/less/less-1.4.0-beta.min",
helper:"app/helper",
jquery_cookie:"libs/jquery/plugin/jquery.cookie",
text:"libs/require/text-2.0.7"
},
shim: {
"lodash": { exports: '_' },
"handlebars": { exports: 'Handlebars' },
"jquery": { exports: '$' },
"backbone": {
//These script dependencies should be loaded before loading
//backbone.js
deps: ["helper", "lodash", "jquery"],
//Once loaded, use the global "Backbone" as the
//module value.
exports: "Backbone"
},
"jquery_cookie": {
deps: ["jquery"]
//,exports:"$"
},
"less": {
exports:"less"
}
}
// This is appended to every module loading request, for cache invalidation purposes
// comment it on production
, urlArgs: "bust=" + (new Date()).getTime()
});
require(["jquery"], function ($) {
$("body").empty();
});
:
이
잘 config.js을 작동 내 fole입니다 내 생각에 jQuery를로드하지 않기 때문에 함수의 오류가 정의되지 않았다.default.ctp
require(["jquery"], function ($) {
$("body").empty();
});
내가 deafult.ctp에 jQuery를 사용할 수없는 이유는 무엇
? 모든 파일에 매핑해야합니까? 나는 그렇게 생각하지 않는다, 누군가 나를 도울 수 있냐? 감사합니다.
여전히 문제가 있습니까? 그렇다면 어떻게 극복 했습니까? – w3jimmy