关于ES6的模块引入我在这里就简单的说明下
首先得说明下一个js文件模块的导出命令export
一般只设置一个,如果只有一个就用export default
多个就使用对象封装export { ...args }
一、多个参数导出和接收
const first = 'first'
const second = 'second'
const third = 'third'
export {
first,
second,
third as reNameThird,
}
import { first as reNameFirst, second, reNameThird } from './xxx.js'
// reNameFirst = 'first', second = 'second', reNameThird = 'third'
二、当只有一个参数时
const first = 'first'
export default first
import randName from './xxx.js'
// randName = 'first'