Home > Web Front-end > Front-end Q&A > Is front-end es6 modular development?

Is front-end es6 modular development?

WBOY
Release: 2022-08-18 16:15:18
Original
1803 people have browsed it

The front-end es6 is a modular development; the es6 modular specification is a modular development specification common to the browser and server, which defines that each JavaScript file is an independent module and can be imported into other module members for use The import keyword and the export keyword are used to share module members externally.

Is front-end es6 modular development?

The operating environment of this tutorial: Windows 10 system, ECMAScript version 6.0, Dell G3 computer.

Front-end es6 is modular development

ES6 modular specification is a common modular development specification for browser side and server side. Its emergence has greatly reduced the modular learning costs of front-end developers. Developers do not need to learn additional modular specifications such as AMD (AMD yes!!! XD), CMD or CommonJS.

ES6 modularization specification defines:

Each js file is an independent module

Use the import keyword to import other module members

Use the export keyword to share module members externally

Experience ES6 modularization in node.js

Make sure v14.15.1 or higher is installed Version of node.js

Add "type": "module" node to the root node of package.json

Is front-end es6 modular development?

Default export and default Import

Export default can only be used once in each js script, otherwise an error will be reported

// 默认导出
// 每个js脚本里面只能使用唯一一次 export default ,否则会报错
let m1 = 10
let m2 = 20
let f1 = () =>{}
 
export default {
    m1,
    f1
}
Copy after login
// 默认导入
// 路径务必将文件后缀写上
import i1 from './01.默认导出.js'
 
console.log(i1)
Copy after login

Is front-end es6 modular development?

[Related recommendations:javascript Video tutorialweb front-end

The above is the detailed content of Is front-end es6 modular development?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
es6
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template