如何使用export default
and module.exports
在同一个文件中。
/******** 出口 ********/
export default function () { ... };
module.exports = {
A,
B,
C
};
如何导入它们?
很确定这是不可能的 - 默认导出基本上与您分配给的对象(或其他表达式)相同module.exports
。最好只使用一种语法风格(module.exports
or export
)始终如一。如果您想要导出默认值and也导出其他东西,考虑使用命名导出来代替,export
syntax:
// define A, B, C
export default function() { ... };
export { A, B, C };
并导入,例如
import fn, { A } from './module';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)