导出的内容

有且仅有六种声明语法,export 只能导出这六种声明语法所声明的标识符,并且在导出时将它们统一称为名字。

解析 export

  1. // 导出“(声明的)名字”
  2. export <let/const/var> x ...;
  3. export function x() ...
  4. export class x ...
  5. export {x, y, z, ...};
  6. // 导出“(重命名的)名字”
  7. export { x as y, ...};
  8. export { x as default, ... };
  9. // 导出“(其它模块的)名字”
  10. export ... from ...;
  11. // 导出“值”
  12. export default <expression
  13. export default 2; // as state of the module, etc.
  14. export default "some messages"; // data or information