
上QQ阅读APP看书,第一时间看更新
Consuming a module
In ES2015, we use the import and from keywords to import one or several constructs like so:
import { SomeConstruct } from './module';
The imported file looks like this:
export let SomeConstruct = 5;
The basic operations involved, working with ES2015 modules, can be summarized as follows:
- Define a module and write the business logic of the module
- Export the constructs you want to make public
- Consume said module with an import keyword from a consumer file
Of course there is a bit more to it than that, so let's look at what else you can do in the next subsection.