共三种:
- 第一种
// 导出 (index.js)
export default {
userName: 'xxx',
user: function(){
...
}
}
// 导入
import user from 'index.js'
- 第二种
// 导出 (index.js)
export const userName= 'xxx'
export function user() {
...
}
// 导入{解构赋值}
import {userName,user} from 'index.js'
- 第三种
// 导出 (index.js)
export const userName= 'xxx'
export function user() {
...
}
// 导入(包装成一个对象)
import * as userInfo from 'index.js'
userInfo.userName
userInfo.user()