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

The method of loading ES6 module Syntax

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

Share

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

This article mainly introduces the relevant knowledge of ES6 module grammar loading method, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this ES6 module grammar loading method article. Let's take a look at it.

Export: to expose is to expose the interface

Import: introduce, literally, introduce an interface

Export {}

Exportfunctiondemo () {}

Exportvardemo1

The two export above can be abbreviated as

Functiondemo () {}

Vardemo1

Export {demo,demo1}

Import {}

Accordingly, of course, there is import.

Import {demo,demo1} from..path

Of course, you can also write another way to write import*asnamefrom..path and then quote it like name.demo ().

Exportdefault

And there is exportdefault.

You can only use exportdefault once in a file.

Exportdefaultfunctiondemo () {}

And then when import

Importdefault

Importname (the name is chosen at random) from..path

See this? no curly braces.

But

Precisely because the exportdefault command actually outputs a variable called default, it cannot be followed by a variable declaration statement.

So exportdefaultvara=1 will report an error if he writes like this!

Vara=1

Exportdefatulta

This is also possible.

A module of export*from

This export* ignores the interface of the output of the module's exportdefault

In that case, does a certain module of import*from fail to import the exportdefault interface defined by the module?

This is the end of this article on "the method of ES6 module Grammar loading". Thank you for reading! I believe you all have a certain understanding of the knowledge of "ES6 module Grammar loading method". If you want to learn more, you are welcome to follow the industry information channel.

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