如何让下拉按钮在React中的卡片中工作?
我正在建设的React和使用顺风css卡来显示API信息。我不想显示所有的信息一次,所以计划使用下拉菜单说“显示更多”,但不知何故,它不会工作。按钮显示,但当点击什么也不会发生。这里是下面的代码,这也适用于从顺风官方网站的下拉代码,所以我的应用程序有什么问题,我不能弄清楚。
您可以看到代码显示here
谢谢
<h5 class="text-gray-900 text-xl leading-tight font-medium mb-2">Card title</h5>
<p class="text-gray-700 text-base mb-4">
Some quick example text to build on the card title and make up the bulk of the card's
content.
</p>
<button
class="dropdown-toggle inline-block px-6 py-2.5 bg-purple-600 text-white font-medium text-xs leading-tight uppercase rounded shadow-md hover:bg-purple-700 hover:shadow-lg focus:bg-purple-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-purple-800 active:shadow-lg active:text-white transition duration-150 ease-in-out flex items-center whitespace-nowrap"
type="button"
id="dropdownMenuButton2"
data-bs-toggle="dropdown"
aria-expanded="false"
>
SHOW MORE
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="caret-down"
class="w-2 ml-2"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 320 512"
>
<path
fill="currentColor"
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
></path>
</svg>
</button>
<ul
class="dropdown-menu min-w-max absolute hidden bg-white text-base z-50 float-left py-2 list-none text-left rounded-lg shadow-lg mt-1 hidden m-0 bg-clip-padding border-none bg-gray-800"
aria-labelledby="dropdownMenuButton2"
>
<h6
class="text-gray-400 font-semibold text-sm py-2 px-4 block w-full whitespace-nowrap bg-transparent"
>
Dropdown header
</h6>
<span
class="text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent text-gray-300"
>Dropdown item text</span
>
<li>
<a
class="dropdown-item text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent text-gray-300 hover:bg-gray-700 hover:text-white focus:text-white focus:bg-gray-700 active:bg-blue-600"
href="#"
>Action</a
>
</li>
<li>
<a
class="dropdown-item text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent text-gray-300 hover:bg-gray-700 hover:text-white focus:text-white focus:bg-gray-700"
href="#"
>Another action</a
>
</li>
<li>
<a
class="dropdown-item text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent text-gray-300 hover:bg-gray-700 hover:text-white focus:text-white focus:bg-gray-700"
href="#"
>Something else here</a
>
</li>
<li><hr class="h-0 my-2 border border-solid border-t-0 border-gray-300 opacity-25" /></li>
<li>
<a
class="dropdown-item text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent text-gray-300 hover:bg-gray-700 hover:text-white focus:text-white focus:bg-gray-700"
href="#"
>Separated link</a
>
</li>
</ul>
</div>
</div>
1条答案
按热度按时间osh3o9ms1#
只需从
ul
标签中删除hidden
类,就可以使用flowbite或daisyui等组件库之一