美文网首页
RequireJs入门

RequireJs入门

作者: funmore | 来源:发表于2016-04-06 10:19 被阅读46次

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入门

    一:什么是requireJS RequireJS 是一个JavaScript模块加载器。它非常适合在浏览器中使...

  • RequireJs入门

    the relationship between ''require" & "requirejs" it is...

  • requireJs使用入门

    requireJS RequireJS是一个工具库,主要用于客户端的模块管理。它可以让客户端的代码分成一个个模块,...

  • RequireJS 入门指南

    英文原文:https://www.codeproject.com/articles/625262/getting-...

  • AMD/RequireJS 使用入门

    参考资料 RequireJS 中文网Javascript模块化编程(三):require.js的用法——阮一峰 前...

  • Requirejs常用配置和应用

    requirejs、require方法冲突 如果加载了多个requirejs脚本,每个requirejs会判断是否...

  • vuex入门实例2

    vuex入门实例2 这章节我准备以requirejs模块化,讲解下如何快速上手vuex 源码地址 工程代码结构如下...

  • 模块化

    RequireJS官网:www.requirejs.org 为什么使用RequireJS 1、有效的防止变量冲突2...

  • RequireJS模块化

    RequireJS官网:www.requirejs.org 为什么使用RequireJS1、有效的防止变量冲突2、...

  • requireJS实践

    开始使用requireJS 文件引入直接在页面上引入requireJS文件。requireJS改变了传统scrip...

网友评论

      本文标题:RequireJs入门

      本文链接:https://www.haomeiwen.com/subject/dwtmlttx.html