标签: react

  • react-router-dom版本v6的路由匹配可选参数

    react router v4路由匹配可选参数

    <Route path="detail/:bookid(/:page)" element={<Detail />} />

    react router v5路由匹配可选参数

    <Route path="detail/:bookid/:page?" element={<Detail />} />

    react router v6路由匹配可选参数

    <Route path="detail/:bookid">
        <Route path=":page" element={<Detail />} />
        <Route path="" element={<Detail />} />
    </Route>
  • react中dangerouslySetInnerHTML渲染HTML文本

    小心地渲染HTML

    <div dangerouslySetInnerHTML = {{ __html: checkMessages.details }} />
    <div dangerouslySetInnerHTML={{ __html: '<div>123</div>' }} />