javascript module
导出 导入#
// npm init,在生成的package.json中,添加"type": "module"
// 再 index.html <script type="module"></script>
// util.js  export
/**
 * 获取格式时间
 * @param {Date} date
 */
export function formatDate(date) {
  return `${date.getFullYear()}-${
    date.getMonth() + 1
  }-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
}
//index.js import
import { formatDate } from "./utils.js";
console.log(formatDate(new Date()));