如何在新的 es6 模块语法中对这种(重新)导出进行编码:
数学.js
module.exports = {
PI: 3.14
};
模块.js
const myMath = require('./math.js');
function myFunc() {}
module.exports = {
PI: myMath.PI, // now is this done in es6?
myFunc: myFunc
};
最佳答案
另一种方法是使用 ES6 提供的重新导出功能:
# math.js
export const PI = 3.14;
# module.js
export {PI} from './mymath.js';
export function myFunc() { /* TODO */ }
关于javascript - 如何在新的 es6 模块语法中表达此 Node 导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37787376/