You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//a.js 使用default,只导出一个
export default 1
// 导入名称随意,不加大括号
import A from 'a.js'
import myA from 'a.js'
import sth from 'a.js'
//a.js,命名导出,可导出多个
export const A = 42
export const B = function(){}
//导入根据名称,且加大括号,可全部导出为一个对象
import {A} from 'a.js'
import {B} from 'a.js'
import * as myObject from 'a.js'
console.log(myObject.A)
es6 modules
es6模块出现之前,js的唯一全局作用域容易出错,随着app越来越复杂,诸如命名冲突和安全问题,这才诞生了module。
When to use the curly braces
Exploring ES6: Modules
Understanding ES6: Modules
dynamic Import
来自stage3,该方法返回一个Promise对象用于在需要时进行导入操作js。
css也可以导入
dynamic import
proposal
The text was updated successfully, but these errors were encountered: