我是 React Router 的新手。这是我的应用程序组件。StudentDetail组件包含转到出勤页面的链接。其作用是呈现出勤组件,但继续在新选项卡中显示StudentDetail的内容。我想要什么:在新选项卡中仅呈现考勤组件?有没有办法做到这一点?提前致谢。
import {
BrowserRouter as Router,
Route,
Switch,
} from "react-router-dom";
import "./App.css";
import Attendance from "./Components/Attendance/Attendance";
import StudentDetail from "./Components/StudentDetail/StudentDetail";
export const StudentContext = createContext();
const StudentData = {
name: "Faisal Rehman",
rollNo: "BCSF17M019",
courses: [
{ courseName: "Computer Architecture", courseAttendance: "" },
{
courseName: "Enterprise Application Development",
courseAttendance: "",
},
{ courseName: "Computer Vision", courseAttendance: "" },
{ courseName: "Mobile Computing", courseAttendance: "" },
],
};
function App() {
return (
<Router>
<div className="App">
<StudentContext.Provider value={StudentData}>
<StudentDetail />
<Switch>
<Route exact path="/attendance" component={Attendance} />
</Switch>
</StudentContext.Provider>
</div>
</Router>
);
}
export { App };
慕的地8271018
狐的传说
相关分类