问题
I want to use crossroads.js with require.js to determine what file to require based on the URL.
I have crossroads set as a dependancy in a Router.js file and if I console.log(crossroads) straight out from the crossroads.js file I get the crossroads object. However it isnt getting passed to the Router.js file, its null or undefined... Wonder if anyone has had this issue before?
Cheers in advance.
回答1:
Crossroads.js works with RequireJS since the beginning (I use RequireJS on all my projects) you probably had some misconfiguration on your paths or expected the global crossroads var to be exposed (which doesn't happen on an AMD environment) or maybe crossroads was being loaded before RequireJS (which would skip the AMD define process).
来源:https://stackoverflow.com/questions/8618444/crossroads-js-and-require-js