导出变量or常量
let language = 'Java'
const address = ['北京', '上海', '广东', '深圳']
export {
language,
address
}
导出函数 & 使用as重命名
function log(content) {
console.info(content)
}
const logwarn = (content) => {
console.warn(content)
}
export {
log as logInfo,
logwarn
}
导出对象
const data = {
name: 'OSpoon',
age: 18
}
export {
data
}
默认导出
const types = ['java','python','js']
export default types
直接导入
import types, {data, address, language, logInfo, logwarn} from './model'
修改导入名称
import {data as list} from './model'
批量导入
import * as model from './model'
本文使用 mdnice 排版