【发布时间】:2021-06-17 16:14:57
【问题描述】:
在浏览了节点文档之后,我对caching 有了一点了解。使用
module.exports{constant_1, constant_2} 将缓存其分配的值,因此每次调用 require('') 时它都会获取缓存的值,而不是创建一个新值。
example_1.js
const test = 'testValue';
module.export = {test};
example_2.js
const cachedValue = require('../example_1.js');
console.log(cachedValue);
但是当我们使用下面的语法时会发生缓存吗?
也导出{constant_1, constant_2} 语句?
example_1.js
const test = 'testValue';
export {test};
example_2.js
import {test} from "example_1";
console.log(test);
【问题讨论】:
标签: javascript node.js ecmascript-6