Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当对象具有ID时,像undefined这样的对象的React map返回ID_Javascript_Reactjs_Typescript - Fatal编程技术网

Javascript 当对象具有ID时,像undefined这样的对象的React map返回ID

Javascript 当对象具有ID时,像undefined这样的对象的React map返回ID,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,我正在映射数据以生成一个表,但是我得到了对象的所有属性,减去对象id。 但当我打印整个对象阵列时,它就在那里。 我不知道这里发生了什么。 以下是控制台中的输出: import*as React from'React'; 从“react router”导入{RouteComponentProps}; 从'react router dom'导入{Link,NavLink}; 接口FetchLibroDataState{ libroList:LibroData[]; 加载:布尔; } 导出类Fetch

我正在映射数据以生成一个表,但是我得到了对象的所有属性,减去对象id。 但当我打印整个对象阵列时,它就在那里。 我不知道这里发生了什么。

以下是控制台中的输出:

import*as React from'React';
从“react router”导入{RouteComponentProps};
从'react router dom'导入{Link,NavLink};
接口FetchLibroDataState{
libroList:LibroData[];
加载:布尔;
}
导出类FetchLibro扩展React.Component{
建造师(道具){
超级(道具);
this.state={libroList:[],load:true};
fetch('api/Libro/Index')
.then(response=>response.json()作为承诺)
。然后(数据=>{
this.setState({libroList:data,load:false});
控制台日志(数据);
});
//此绑定是使“This”在回调中工作所必需的
this.handleDelete=this.handleDelete.bind(this);
this.handleEdit=this.handleEdit.bind(this);
}
公共渲染(){
让内容=this.state.loading
卡甘多

:this.renderLibroTable(this.state.libroList); 返回 利布罗达托斯酒店 利布罗斯基准塔

新克雷尔酒店

{contents} ; } //处理员工的删除请求 私人手持设备(id:编号){ 如果(!window.confirm(“?”静默eliminar el libro con el ID:“+ID+”?”) 返回; 否则{ fetch('api/Libro/Delete/')+id{ 方法:“删除” })。然后(数据=>{ 这是我的国家( { libroList:this.state.libroList.filter((rec)=>{ 返回(rec.IdLibro!=id); }) }); }); } } 私有handleEdit(id:编号){ this.props.history.push(“/Libro/edit/”+id); } //将HTML表返回给render()方法。 私有renderLibroTable(libroList:LibroData[]){ 返回 Libro ID 自动 名义 社论 法令 慷慨的 阿诺 分离性 康蒂达 图像 紫苏属 {libroList.map(libro=> {libro.IdLibro}A {libro.nombreAutor} {libro.nombre} {libro.社论} {libro.edition} {libro.grando} {libro.ano} {libro.disponibilidad} {libro.cantidad} {libro.imagen} {libro.sinopsis} this.handleEdit(libro.IdLibro)}>Edit| this.handleDelete(libro.IdLibro)}>Delete )} ; } } 导出类LibroData{ IdLibro:number=0; nombreAutor:string=“”; nombre:string=“”; 社论:string=“”; 法令:string=“”; 慷慨:字符串=”; ano:string=“”; disponibilidad:boolean=true; cantidad:number=0; imagen:string=“”; 中文字幕:string=“”; }
我认为您使用的属性名称不正确,请按此操作

...
{libroList.map(libro =>

            <tr key={libro.idLibro}> // i is small caps

                <td></td>

                <td>{libro.idLibro}A</td>
             // remaining code
。。。
{libroList.map(libro=>
//我是小盘股
{libro.idLibro}A
//剩余代码

希望它有帮助

您正在映射
IdLibro
,而数据属性是
IdLibro
是的!它可以工作,非常感谢!!@JakeChavez如果它对您有帮助,请随时接受答案,干杯
...
{libroList.map(libro =>

            <tr key={libro.idLibro}> // i is small caps

                <td></td>

                <td>{libro.idLibro}A</td>
             // remaining code