一、基本使用
// 導出
export let A = 123;
export function test() {
console.log('test')
}
export class Hello{
test(){
console.log('hello test')
}
}
// 導入模塊
import {A,test,Hello} from '/common/index'
二、全部導入
import * as lesson from '/common/index'
三、批量導出,不限制名字:採用export default
let A = 123;
let test = function test() {
console.log('test')
}
class Hello{
test(){
console.log('hello test')
}
}
export default {
A,
test,
Hello
}
// 引入並使用
import demo16 from '/common/index'
console.log(demo16.A);