Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use import in es6

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use import in es6". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use import in es6".

In es6, import is used to load a module with an export interface in another module; after the external interface of the module is defined using the export command, the JS file can load the module through the import command with the syntax of "import export module interface from js file".

This tutorial operating environment: windows10 system, ECMAScript version 6. 0, Dell G3 computer.

What is the use of import in es6

The ES6 module has two main functions: export and import

Export is used to output the variables of this module (a file can be understood as a module).

Import is used to load one module into another module with an export interface.

That is, after the external interface of the module is defined using the export command, other JS files can load the module (file) through the import command.

The following figure (assuming files an and b are in the same directory)

A.js files can also be written according to the following export syntax, but not as intuitive as the above, not recommended.

/ / a.jsexport var sex= "boy" Export var echo=function (value) {console.log (value)} / / because function echo () {} is equivalent to var echo=function () {}, you can also write export function echo (value) {console.log (value)} Thank you for your reading. This is the content of "how to use import in es6". After the study of this article, I believe you have a deeper understanding of how to use import in es6. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report