请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

detail 文件写完之后出现的错误?我是哪个地方写错了?

这是App.tsx 中的代码

import React from 'react';
import styles from './App.module.css';
import{BrowserRouter,Route,Switch} from "react-router-dom"
import {HomePage,SignInPage,RegisterPage, DetailPage} from "./pages"

function App() {
  return (
  <div className={styles.App}>
    <BrowserRouter>
    <Switch>
      <Route exact path="/" component={HomePage}/>
      <Route path="/signin" component={SignInPage} />
      <Route path="/register" component={RegisterPage} />
      <Route path="/detail/:touristRouteId" component={DetailPage} />
      <Route render ={()=><h1>404 not found page go to mars</h1>}/>
    </Switch>

    
    </BrowserRouter>
   
  </div>
  );
}

export default App;

这是DetailPage.tsx 中的代码。

import React from "react";
import {RouteComponentProps} from "react-router-dom"

interface MatchParams {
    touristRouteId: string;
}
export const DetailPage: React.FC<RouteComponentProps<MatchParams>> = (props)=>{
    return (
    <h1> 
        the detail of way of trail, the way ID: {props.match.params}
    </h1>
    )
}

after npm start, there is some wrong here

请帮忙看一下。 多谢多谢!

正在回答 回答被采纳积分+3

插入代码

2回答

提问者 慕UI4249796 2021-03-22 02:15:09

已解决。。。

0 回复 有任何疑惑可以回复我~
提问者 慕UI4249796 2021-03-21 03:35:36

the error

···

Error: Objects are not valid as a React child (found: object with keys {touristRouteId}). If you meant to render a collection of children, use an array instead.

···

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号