I & amp; have read; I want to understand this concept more clearly, so I have made my two files
lorem.js :
var lorem = { }; Lorem.fun1 = function () {console.log ('aaa'); }; ipsum.js :
var ipsum = {}; Ipsum.color = 'a'; Ipsum.fun1 = function () {lorem.fun1 (); }; Depending on Ipsum Lorame I have done something like this in the Shim configuration:
// file name: main.js // Require.js us The shortcut allows the nickname to be configured // The usage will be more clear in this tutorial. Need help .config ({baseUrl: 'js', path: {/ * jquery: [//' https://ajax.googleapis.com/ Ajax / libs / jquery / 2.1.3 / jquery.min ',' Libs / Jquery / jquery '], backbone: [' Libs / Backbone / Backbone '], underscore: [' Libs / underscore / underscores'], * / Ipsum: 'Non Amed / Ipsum', Loram: 'Non Amed / Lore '}, Shim: [/ Jquery: {export:' jQuery '}, underscore: {export:' _ '}, spinal cord: {deps: [' jquery ',' underscores'], export: 'backbone' }, * / Ipsum: {Deps: ['Lorem'], export: 'epsom'}}}); Expected (['ipsum'], function (Ipsum) {console.log (Ipsum);}); However, in console.log (Ipsum) print undefined console. What am i doing wrong
Your mistake is in Shim configuration.
ipsum: {deps: ['lorem'], should be exported: 'epsom'}
Ipsum: {deps: focus on changing case with '. should be a global variable in' Ipsum 'from' ipsum '.ipsuminipsum.js.In Javascript, variable names are case-sensitive, so
IpsumandIpsumare different because you haveIpsum, only < Code> ipsum , it was printedundefined.
No comments:
Post a Comment