Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.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
Reactjs 反应路由问题_Reactjs_React Router - Fatal编程技术网

Reactjs 反应路由问题

Reactjs 反应路由问题,reactjs,react-router,Reactjs,React Router,我对react很新鲜,最近正在建立自己的投资组合网站。但是,我发现路由时存在一个问题。 这是我的路由器: <Switch> <Route exact path='/project' component={ProjectDefault}/> <Route path='/project/:id' component={ProjectDetail}/> </Switch> 这是我的ProjectDetail组件: expor

我对react很新鲜,最近正在建立自己的投资组合网站。但是,我发现路由时存在一个问题。 这是我的路由器:

 <Switch>
     <Route exact path='/project' component={ProjectDefault}/>
     <Route path='/project/:id' component={ProjectDetail}/>
 </Switch>

这是我的ProjectDetail组件:

export const ProjectDetail = (props) => {
    return (
        <div className="project-detail w3-animate-zoom">
            <div className="col-lg-12 project-detail-header">
                <h2 className="name text-white">{project.name}</h2>
                <hr className="split-line"/>
                <h4 className="skills text-white"
                             {project.description}</h4>
                <h4 className="skills text-black">Developed With</h4>
                <h4 className="skills text-white">{project.tech}</h4>
            </div>
        </div>

    )
}
export const ProjectDetail=(道具)=>{
返回(
{project.name}


我没有看到一个反应器组件的关闭支架,没有错误,我没有把整个代码放在这里,我确信没有错误。当我使用const时,它工作得很好。当我使用XXX类Exchange Read。组件,它将无法工作。你能检查控制台是否有错误,这不是问题,它应该工作。你检查了关闭Par吗?enthesisit在我的控制台中是干净的,我非常确定代码是好的
export class ProjectDetail extends React.Component {
        constructor(){super();...//setting state}
        render() {
            return (
            <div className="project-detail w3-animate-zoom">
                <div className="col-lg-12 project-detail-header">
                    <h2 className="name text-white">
   {this.state.project.name}</h2>
                    <hr className="split-line"/>
                    <h4 className="skills text-white">
   {this.state.project.description}</h4>
                    <h4 className="skills text-black">Developed 
   With</h4>
                    <h4 className="skills text-white">
   {this.state.project.tech}</h4>
                </div>
            </div>

        )
}