导出
// module.js
// esm 默认导出
//export default 'Hello world'
export default {
foo: 'Hello foo.',
bar: 'Hello bar.'
}
// esm 普通导出
export function foo() {
console.log( 'Hello from foo.' );
}
export const bar = 'Hello from bar.';
导入
// index.js
// esm 导入默认
import x from './module.mjs'
import { foo, bar } from './module.mjs'
console.log( x.foo );
console.log( x.bar );
foo();
bar();
标签:bar,导出,导入,export,模块,foo,Hello,ES
From: https://www.cnblogs.com/isky0824/p/16880108.html