简体   繁体   English

_.get不适用于module.exports对象

[英]_.get does not work with module.exports object

I have a node file that exports an object 我有一个导出对象的节点文件

(path './../../config/cloud.js): (路径'./../../config/cloud.js):

module.exports = {
   some: {
       property: 1
   }
}

if I use the following code: 如果我使用以下代码:

const config   = require('./../../config/cloud');
const _  = require('lodash');
console.log(_.get(config, 'some.property'); // prints undefined
console.log(config.some.property); // print 1

Can you help me to see what I'm doing wrong? 您能帮我看看我做错了什么吗? Thanks 谢谢

EDIT: I expect that the first console.log prints 1 instead of undefined . 编辑:我希望第一个console.log打印1而不是undefined

由于某种原因, _是未定义的,并引发了某种异常,该异常在某种程度上在我的日志中不可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM