V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ghostgril
V2EX  ›  前端开发

webpack, node, es6 的 require 和 import 如何区分

  •  
  •   ghostgril · 2018-05-04 20:38:56 +08:00 · 1385 次点击
    这是一个创建于 2187 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 webpack,node 和 es6 三者的环境下开发,完全搞不懂这些关系了。node 有 require 方法,webpack 也有 require 和 require.context,搞不清这几种模块方法的区别,再加上使用 vue 的 import 方法

    3 条回复    2018-05-04 20:59:56 +08:00
    ghostgril
        1
    ghostgril  
    OP
       2018-05-04 20:39:08 +08:00
    晕了
    ghostgril
        2
    ghostgril  
    OP
       2018-05-04 20:53:25 +08:00
    在 vue 文档里看到这个

    require(['./my-async-component'], resolve)

    这个是上面语法?
    SuperMild
        3
    SuperMild  
       2018-05-04 20:59:56 +08:00
    typescript 教程里 Code Generation for Modules 那部分,有各种 import require 的对比。

    http://www.typescriptlang.org/docs/handbook/modules.html
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5340 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:11 · PVG 16:11 · LAX 01:11 · JFK 04:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.