RequireJs入门

the relationship between ''require" & "requirejs"

it is the same!
you can try

if(require===requirejs){
      alert(true);
    }```
it can be tested!

## the relationship between 'require' $ 'define'

require(['a'], function(a) {
// some code
});
//load this 'a' module ,and run the function

define(['b','c','d','e'], function() {
//some code
});
// If you need a XXX, then load these other things first, then return the result of this function.

a define *might never be called*.
As long as there is only one define , it will register that module as available under that filename. However, define modules are only loaded once a require function asks for each of them.

## './'  & '../' &'paths'
./ means the root of your directory and anything appended to ./ is the module in your same directory.
./module is useful because you don't have to set paths in your config.paths property.
paths is like a absolute path configured in the project , you can always use require('module') in your code as you have already configure it in configure.js in paths form
../ means the root of the project **which is the baseUrl location!!**

root
dir
file1
file2
dir2
file1
file2


If you are in root/dir . refers to root/dir so ./file1 refers to /root/dir/file1
.. refers to root so ../file1 doesn't exist (root/file1)

.  represent the current working directory
.. represent the parent directory of the current working directory.

你可能感兴趣的:(RequireJs入门)