ndoejs
// 导出module.exports class Text{}exports.num = 1;// 导入const {num} = require("./index.js");const Text = require("./index.js");
es6
一个非常尴尬的事情是,node13支持es6模块了 ~~~~~ 啊哈哈
// 导出export const num = ()=> 123;default export class Text{}// 导入import {num} from "./index.js";import Test from "./index.js";import Text as t from "./index.js"// 直接导出export {num} from "./index.js"export * from "./index.js"e
浏览器中使用
注意,
