简体   繁体   English

类型错误:无法读取 recatjs 中未定义的属性(读取“地图”)

[英]TypeError:Cannot read properties of undefined (reading 'map') in recatjs

I get this error called Cannot read properties of undefined (reading 'map') this is my code please help me fix it我收到此错误,称为无法读取未定义的属性(读取“地图”)这是我的代码请帮我修复它

 return ( <div className="row"> <h3>{title}</h3> <div className="row__posters"> {movies.map(movie => { return <img className={`row_poster`} src={`${base_url}`} alt={movie.name} /> })} </div> </div> );

在此处输入图像描述

try movies?.map or试试看电影?.map 或

if(movies == undefined){
return;
}

return (
    <div className="row">
      <h3>{title}</h3>

      <div className="row__posters">
      {movies.map(movie => {
          return <img
            className={`row_poster`}
            src={`${base_url}`}
            alt={movie.name} />
        })}
      </div>
    </div>
  );```

change:改变:

{movies.map(movie => {
          return <img
            className={`row_poster`}
            src={`${base_url}`}
            alt={movie.name} />
        })}

to:到:

{movies && movies.map(movie => {
          return <img
            className={`row_poster`}
            src={`${base_url}`}
            alt={movie.name} />
        })}

暂无
暂无

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

相关问题 TypeError:无法读取未定义的属性(读取“地图”) - State 返回未定义 - TypeError: Cannot read properties of undefined (reading 'map') - State returns undefined TypeError:无法读取未定义的属性(正在读取“映射”)(JavaScript 数组映射) - TypeError: Cannot read properties of undefined (reading 'map') (JavaScript array map) 类型错误:无法读取未定义的属性(读取“地图”)Table.render - TypeError: Cannot read properties of undefined (reading 'map') Table.render 反应:类型错误:无法读取未定义的属性(读取“地图”) - React: TypeError: Cannot read properties of undefined (reading 'map') 未捕获的类型错误:无法读取未定义的属性(读取“地图”) - Uncaught TypeError: Cannot read properties of undefined (reading 'map') TypeError:无法读取未定义的属性(读取“地图”)NEXTJS - TypeError: Cannot read properties of undefined (reading 'map') NEXTJS 未捕获的类型错误:无法读取未定义的属性(读取“地图”)反应 - Uncaught TypeError: Cannot read properties of undefined (reading 'map') React TypeError: Cannot read properties of undefined (reading 'map') - AirBnb 克隆教程 - TypeError: Cannot read properties of undefined (reading 'map') - AirBnb Clone Tutorial TypeError:无法在 React-Views 中读取未定义的属性(读取“地图”) - TypeError: Cannot read properties of undefined (reading 'map') in React-Views TypeError:无法在反应 JS 中读取未定义的属性(读取“地图”) - TypeError: Cannot read properties of undefined (reading 'map') in react JS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM