为什么链接不会显示在我的下拉菜单中,而是显示在下拉菜单之外?

时间:2019-02-23 17:58:23

标签: php html html5 laravel debugging

我想在单击下拉菜单时显示DashboardLogout,但是下面显示了当前代码,但没有出现。

在尝试调试期间,我只是将DashboardLogout移到了div之外,的确显示了它们,但它们不是下拉列表的一部分。

为什么我的下拉菜单不显示?

<li class="nav-item dropdown">
    <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
       <?php echo e(Auth::user()->name); ?> <span class="caret"></span>
    </a>

    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
         <a href="/dashboard">Dashboard</a>
         <a class="dropdown-item" href="<?php echo e(route('logout')); ?>"
                   onclick="event.preventDefault();
                                             document.getElementById('logout-form').submit();">
                        <?php echo e(__('Logout')); ?>

         </a>
          <form id="logout-form" action="<?php echo e(route('logout')); ?>" method="POST" style="display: none;">
              <?php echo csrf_field(); ?>
          </form>
     </div>
 </li>

1 个答案:

答案 0 :(得分:0)

尝试使用我为您编写的代码,而不是您的代码。应该工作,让我知道!

<div class="container">
  <div>
    <h1>Welcome</h1>
    <h2>Some text that can change length/height</h2>
  </div>
  <div>
    <div class="rest">I want this block to be the remaining 100% height</div>
  </div>
</div>

如果您想在导航栏上使用引导程序3

尝试此操作
<div class="dropdown">
  <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"><?php echo e(Auth::user()->name); ?>
  <span class="caret"></span></button>
  <ul class="dropdown-menu">
    <li><a href="/dashboard">Dashboard</a></li>
    <li><a href="<?php echo e(route('logout')); ?>" onclick="event.preventDefault(); document.getElementById('logout-form').submit();"><?php echo e(__('Logout')); ?></a></li>
    <form id="logout-form" action="<?php echo e(route('logout')); ?>" method="POST" style="display: none;">
      <?php echo csrf_field(); ?>
    </form>
  </ul>
</div>

如果您使用的是引导程序4 ,请尝试以下操作:

<ul class="nav navbar-nav">
  <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php echo e(Auth::user()->name); ?> <span class="caret"></span></a>
    <ul class="dropdown-menu">
      <li><a href="/dashboard">Dashboard</a></li>
      <li><a href="<?php echo e(route('logout')); ?>" onclick="event.preventDefault(); document.getElementById('logout-form').submit();"><?php echo e(__('Logout')); ?></a></li>
      <form id="logout-form" action="<?php echo e(route('logout')); ?>" method="POST" style="display: none;">
        <?php echo csrf_field(); ?>
      </form>
    </ul>
  </li>
</ul>