renderNotFound

    子应用触发渲染全局 404 的方法

    • 类型:function

    • 代码示例:

    1. import React from 'react';
    2. import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
    3. import { renderNotFound, getBasename } from '@ice/stark';
    4. function List() {
    5. return <div>List</div>;
    6. }
    7. function Detail() {
    8. return <div>Detail</div>;
    9. }
    10. export default class App extends React.Component {
    11. render() {
    12. return (
    13. <Router basename={getBasename()}>
    14. <Switch>
    15. <Route exact path="/" component={List} />
    16. <Route path="/detail" component={Detail} />
    17. <Route
    18. component={() => {
    19. // 通知框架应用渲染全局 404
    20. return renderNotFound();
    21. }}
    22. />
    23. </Switch>
    24. </Router>
    25. );
    26. }
    27. }