Require problem loading underscore library

I am using require.version "2.0.0"
And I would like to get the underscore as a local variable:

Here is my code (1).

Why _ is undefined?
How can I get _ inside a function as a local variable


(one)

 require.config({ baseUrl: "./", paths: { 'underscore': 'vendor/js/underscore-min' }, shim: { 'underscore': { exports: 'underscore' } } }); require([ 'underscore' ], function(_) { "use strict"; console.log(_); // undefined }); 
+7
source share
1 answer

Well, just replace exports: 'underscore' with exports: '_' . This requires a connection to the _ module. This way the window._ link will work.

+5
source

All Articles