您的位置:首页 > 房产 > 建筑 > h5浏览器_高端网站设计公司排行榜_seo用什么论坛引流_信息流广告有哪些投放平台

h5浏览器_高端网站设计公司排行榜_seo用什么论坛引流_信息流广告有哪些投放平台

2025/2/24 3:33:26 来源:https://blog.csdn.net/y523648/article/details/143199951  浏览:    关键词:h5浏览器_高端网站设计公司排行榜_seo用什么论坛引流_信息流广告有哪些投放平台
h5浏览器_高端网站设计公司排行榜_seo用什么论坛引流_信息流广告有哪些投放平台

新版本的React-Route (v6或以上,但不排序后续版本还会有修改),移除了Switch,写法和老版本有一些区别,下面分享一个示例:

 JSX文件:

import React, {StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter as Router, Route, Routes ,Link } from "react-router-dom";
import Home from './components/Home';    //根据路由显示的子组件,自己定义
import About from './components/About';  //根据路由显示的子组件,自己定义//路由 begin
export function Navigation() {
return (<nav><ul><li><Link to="/">首页</Link></li><li><Link to="/about">关于</Link></li></ul></nav>)
}export default function App() {return (<Router><Navigation /><Routes><Route path="/" element={<Home />} /><Route path="/about" element={<About />} /></Routes></Router>)
}
//路由 end//错误边界
class ErrorBoundary extends React.Component {constructor(props){super(props)this.state = { hasError: false }}static getDerivedStateFromError(error){return {hasError:true}}componentDidCatch(error, info){console.log(error, info)}render(){ if(this.state.hasError){  return <h1>Something went wrong.</h1>} return this.props.children}
}createRoot(document.getElementById('root')).render(<StrictMode><ErrorBoundary><App /></ErrorBoundary></StrictMode>)

入口html页面引用上面的jsx文件,比如

<script type="module" src="/src/main.jsx"></script>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com