尝试通过组件传递参数
因此,我正在使用电影DB API创建一个应用程序,并且我的演员组成部分将演员ID传递给,以及当我尝试使用该ID链接到人网页时,由于某种原因,我会传递对象。我试图通过数字,有什么办法做到这一点吗?
import React from 'react';
// Styles
import { Wrapper, Image } from './Actor.style'
import { Link } from 'react-router-dom';
const Actor = ({name, character, imageUrl, personId}) => {
console.log(personId);
return(
<Wrapper>
<Link to={`/person/${personId}`}>
<Image src={imageUrl} alt='actor-thumb' />
</Link>
<h3>{name}</h3>
<p>{character}</p>
</Wrapper>
)
}
导出默认演员;
So I am creating an app using the movie DB API and I have this Actor component where I am passing the actor id to and when I try to use that Id to link to the person webpage for some reason I am passing an object instead. I am trying to pass the number, is there any way to do this?
import React from 'react';
// Styles
import { Wrapper, Image } from './Actor.style'
import { Link } from 'react-router-dom';
const Actor = ({name, character, imageUrl, personId}) => {
console.log(personId);
return(
<Wrapper>
<Link to={`/person/${personId}`}>
<Image src={imageUrl} alt='actor-thumb' />
</Link>
<h3>{name}</h3>
<p>{character}</p>
</Wrapper>
)
}
export default Actor;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论