小编jon*_*puc的帖子

反应路由器的嵌套路由。不呈现子路线

我有一个称为Dashboard的父组件,该组件被渲染为Route,如下所示:

const Routes = ({ authenticated }: { authenticated: boolean }) => (

    <Switch>
        <AuthenticatedRoute path="/home" exact={true} component={Dashboard} authenticated={authenticated} />
        <UnauthenticatedRoute path="/login" exact={true} component={Login} authenticated={authenticated} />
        <AuthenticatedRoute path="/onboarding" exact={true} component={Onboarding} authenticated={authenticated} />
        <AuthenticatedRoute path="/meets" exact={true} component={Meets} authenticated={authenticated} />
        <Route component={NotFound} />
    </Switch>

)

export default Routes
Run Code Online (Sandbox Code Playgroud)

在Dashboard组件中,我还要呈现路线,该组件如下所示:

class Dashboard extends React.Component<IProps, {}> {
    public render() {
        return (
            <div>
                <Navigation />

                <Route exact={true} path="/home" component={Home} />
                <Route exact={true} path="/home/profile" component={Profile} />
                <Route exact={true} path="/home/messages" component={Messages} />

                HALLO
            </div>
        )
    } …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router react-router-v4 react-router-dom

3
推荐指数
1
解决办法
1035
查看次数

将数组项打印到列表项中的更简单方法 (JavaScript)

通过书中的一些练习。必须将数组项打印到列表元素中。

这是本书提供的解决方案。

<!doctype html>
<html lang="en">

<head>
  <title>Temperatures</title>
  <meta charset="utf-8">
  <script>
    function showTemps() {
      var tempByHour = new Array();
      tempByHour[0] = 59.2;
      tempByHour[1] = 60.1;
      tempByHour[2] = 63;
      tempByHour[3] = 65;
      tempByHour[4] = 62;
      for (var i = 0; i < tempByHour.length; i++) {
        var theTemp = tempByHour[i];
        var id = "temp" + i;
        var li = document.getElementById(id);
        if (i == 0) {
          li.innerHTML = "The temperature at noon was " + theTemp;
        } else {
          li.innerHTML = "The temperature …
Run Code Online (Sandbox Code Playgroud)

javascript arrays loops

1
推荐指数
1
解决办法
3347
查看次数