跨模块常量 // constants.js 模块 export const A = 1; export const B = 3; export const C = 4; // test1.js 模块 import * as constants from './constants'; console.log(constants.A); console.log(constants.B); // test2.js 模块 import {A, B} from './constants'; console.log(A); console.log(B);