I'm trying to use require js with CakePHP 2.3.8 but I'm not having any luck getting it working. I have the following in my default.ctp file
<script data-main="scripts/main" src="http://localhost/Test/js/require.js"></script>
When I include this, I get the following error Uncaught Error: Script error for: main
I have the following structure
App/
webroot/
js/
require.js
main.js
helper/
date.js
I tried pointing "data-main" to the folder that require.js is in, and the error goes away, however, the date.js script is not loading
<script data-main="http://localhost/Test/js/" src="http://localhost/Test/js/require.js"></script>
I want to include date.js, so in main.js I have the following
require(["date"], function() {
});
I'm using chrome, and when I check the scripts and network tab, date.js does not show up.
Try changing data-main='http://localhost/Test/js/'
to data-main='http://localhost/Test/js/main'
. To get date.js
to work, you must do something like:
require(['helper/date'], function() {
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.