导入如何与节点模块一起引用模块的导出名称?

时间:2016-08-18 01:37:39

标签: node.js import module npm export

当index.js执行以下导入时,'redux'指的是什么?我尝试在node_modules中查找redux包的src目录,但找不到导出'redux'的任何内容。这个命名空间是通过package.json文件中的依赖项提供的吗?

import { createStore } from 'redux'

1 个答案:

答案 0 :(得分:2)

它指的是redux模块。 CreateStore它是模块的一部分。你应该阅读文档https://github.com/reactjs/redux 在es6语法中,您可以使用这些模板

    import defaultMember from "module-name";
    import * as name from "module-name";
    import { member } from "module-name";
    import { member as alias } from "module-name";
    import { member1 , member2 } from "module-name";
    import { member1 , member2 as alias2 , [...] } from "module-name";
    import defaultMember, { member [ , [...] ] } from "module-name";
    import defaultMember, * as name from "module-name";
    import "module-name";