0

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.

4

1 回答 1

1

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() {

});
于 2013-10-10T01:31:45.437 回答