未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
Uncaught TypeError: Cannot read property 'name' of undefined even it exist
更新以简化问题:
通过字符串索引访问属性时出现问题,但使用密钥有效
for(var i in this.props.data[this.props.activeMenu]){
console.log(i, this.props.data[this.props.activeMenu][i]);
}
输出:
url /api/timekeeping
name Timekeeping
submenus Object {dtr: Object, schedules: Object}
id timekeeping
但我在调用console.log(i, this.props.data[this.props.activeMenu]['name'])
时出错。name
是一个有效的密钥,因为它是在我检查密钥时显示的。
当我试图访问console.log(this.props.data['timekeeping']['name'])时,我收到了这个错误Uncaught TypeError:无法读取未定义的属性'name'
我认为您应该使用:console.log(this.props.data['timekeeping'].name).
试试看。
相关文章:
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- 骨干's Router.execute(callback,args,name)方法获取未定义的名称
- Sailsjs:TypeError:无法读取属性'name'的未定义
- 访问模板中的属性时出现问题-除'name'显示错误'没有定义[attributename];
- 无法设置属性'name'的未定义JS
- 为什么 this.name 未定义
- 无法读取属性“”;name”;的未定义
- Javascript:“;无法读取属性“”;name”;未定义的“;本地javascript代码出错
- HTML表单属性“;name”;没有在Firefox中定义
- 未捕获的类型错误:无法读取属性"name'的定义
- 如何在自定义对象上指定.constructor.name
- 从用var定义的函数中获取name
- Internet Explorer中未定义constructor.name
- 为什么函数属性定义在对象本身上(例如Function.name),而方法定义在Function.prototype上?
- 如果我使用 Object.defineProperty() 定义 “name” 属性,Error.prototype.t
- Javascript未定义为属性*name*
- 在数组中的复选框上调用.name将返回未定义
- 未捕获的错误:不匹配的匿名定义()模块:函数定义(name, global)
- AngularJS: NameError: name没有定义
- 当使用window.frames[name]访问时,iframe contentWindow未定义