javascript - es6 require parameter problem
phpcn_u1582
phpcn_u1582 2017-05-19 10:39:44
0
3
688

I haven’t found much specific usage of es6 require. Most of them are briefly introduced to load modules, such as
const es_namespace = require('./es');
But I have seen this use of resolve elsewhere. => require(['../pages/login/'], resolve), what does this require function mean? Is there any official documentation? Or go into details?

phpcn_u1582
phpcn_u1582

reply all (3)
Ty80

ES6 modularization uses import and export. For details, you can see "Understanding ECMAScript6" https://sagittarius-rev.gitbo...,
Chapter 13 of this book uses modules to encapsulate code. I think it is very well written. , very clear and concise.

The require you are talking about is a js library RequireJS,
Chinese document http://www.requirejs.cn/,
This tutorial is also good http://www.runoob.com/w3cnote...

    左手右手慢动作

    Becauserequirerequire.jsis a library, you can take a look at Ruan Yifeng’s introduction on how to use require.js

      漂亮男人
      当 Node 遇到 require(X) 时,按下面的顺序处理。 (1)如果 X 是内置模块(比如 require('http'))   a. 返回该模块。   b. 不再继续执行。 (2)如果 X 以 "./" 或者 "/" 或者 "../" 开头   a. 根据 X 所在的父模块,确定 X 的绝对路径。   b. 将 X 当成文件,依次查找下面文件,只要其中有一个存在,就返回该文件,不再继续执行。 X X.js X.json X.node   c. 将 X 当成目录,依次查找下面文件,只要其中有一个存在,就返回该文件,不再继续执行。 X/package.json(main字段) X/index.js X/index.json X/index.node (3)如果 X 不带路径   a. 根据 X 所在的父模块,确定 X 可能的安装目录。   b. 依次在每个目录中,将 X 当成文件名或目录名加载。 (4) 抛出 "not found"

      This is how require works.
      ['../pages/login/'] may load all files under "../pages/login/"
      You can refer to require() source code interpretation

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!