默认导出 只导出一个
//导出
const obj={
name:"syukinmei"
}
export default obj // 默认导出 导出1个
//导入
import obj form './utils/index' // 无需加后缀!!!
console.log(obj.name) // "syukinmei"
批量导出 可以导出多个
// 导出
export const obj={
name:'syukinmei'
}
export const arr=[1,2,3,4,5]
//导入写法1
import {obj,arr} from './utils/index'
console.log(obj.name,arr) // "syukinmei" [1,2,3,4,5]
//导入写法2
import * as type from './utils/index' // type为自定义变量
console.log(type.obj.name) // 'syukinmei'
console.log(type.arr) // [1,2,3,4,5]
//导出时起别名 as 为alias缩写
import {obj as OBJ,arr as Arr} from './utils/index'
console.log(OBJ.name) // 'syukinmei'
console.log(Arr) // [1,2,3,4,5]