【问题标题】:Reactjs Ant-Design Menu - Submenu doesn't pop outReactjs Ant-Design 菜单 - 子菜单不弹出
【发布时间】:2018-10-31 08:15:07
【问题描述】:

我在我的 react 项目中使用了 Reactjs Ant-Design Menu。 我一度卡住了。 当我在移动视图中登录我的网站并单击 Ant-Design 菜单的子菜单时。 在我们点击屏幕之前它是不可点击的,其他菜单项工作正常, 如果有人对此有任何解决方案,请帮助我。 那是我的代码:

          <Menu
            theme="dark"
            mode="inline"
            defaultOpenKeys={["sub1"]}
            defaultSelectedKeys={[selectedKey]}
          >
           <Menu.Item key="1" >
              <Icon type="dashboard" />
              <span>dashboard</span>
              <Link to="/home" />
            </Menu.Item>
            <SubMenu
              key="sub1"
              title={
                <span>
                  <Icon type="user" />
                  <span>account</span>
                </span>
              }
            >                
              <Menu.Item key="2">
                <Icon type="line-chart" />
                <span>subscriptions</span>
                <Link to="/subscriptions" />
              </Menu.Item>

              <Menu.Item key="3">
                <Icon type="transaction" />
                <span>transactions</span>
                <Link to="/transactions" />
              </Menu.Item>

              <Menu.Item key="4">
                <Icon type="profile" />
                  <span>profile</span>
                  <Link to="/profile" />
              </Menu.Item>

              <Menu.Item key="5">
                <Icon type="key" />
                  <span>password</span>
                  <Link to="/password" />
              </Menu.Item>
            </SubMenu>

            <Menu.Item key="7" >
              <Icon type="question-circle" />
              <span>Help</span>
              <Link to="/help" />
            </Menu.Item>

            <Menu.Item key="8" onClick={this.logOut}>
              <Icon type="upload" />
              <span>logout</span>
            </Menu.Item>
          </Menu>

【问题讨论】:

    标签: reactjs antd


    【解决方案1】:

    将图标和文本外的链接包装到代码中的每个菜单项。

     <Link to="/subscriptions">
        <Icon type="line-chart" />
         <span>subscriptions</span>
        </Link>
    

    【讨论】:

      猜你喜欢
      • 2020-06-15
      • 2019-01-31
      • 2019-05-04
      • 1970-01-01
      • 2019-02-28
      • 1970-01-01
      • 2016-04-15
      • 2011-06-13
      • 2020-06-03
      相关资源
      最近更新 更多