export/export default
sonder 小杯

ES导入导出模块

ES模块较为清晰,时常在项目中使用

image

  • export栗子
1
2
3
4
5
6
7
export function abc (a,b){
return a + b
}
// 或者这样导出
export {abc}
// 引入
import {abc} from './index.js'
  • export default栗子
1
2
3
4
5
6
7
8
9
10
11
12
function abc (a,b){
return a +b
}
function ttt (a,b){
return a +b
}
export default{
abc,
ttt
}
// 引入
import methods from './index.js'
  • 本文标题:export/export default
  • 本文作者:sonder
  • 创建时间:2020-05-19 17:35:39
  • 本文链接:https://sonderss.github.io/2020/05/19/export-default/
 评论