ES6 三种不同的模块导入方式

 1. 通用的导入方式

        // 引入 m1.js
        import * as m1 from './js/3-m1.js'
        console.log(m1)

        // 引入 m2.js
        import * as m2 from './js/4-m2.js'
        console.log(m2) 

        //  引入 m3.js
        import * as m3 from './js/5-m3.js'
        console.log(m3)

2. 解构赋值形式

        import {school, teach} from './js/3-m1.js'
        import {school as xuexiao, teach as jiao} from './js/4-m2.js'
        import {default  as m3} from './js/5-m3.js'

        console.log(xuexiao, jiao)
        console.log(m3)

3. 简便形式 (针对默认暴露)

        import m3 from './js/5-m3.js'
        console.log(m3)

你可能感兴趣的:(ES6知识,es6,javascript,前端)