我完全按照这些指示去做:
https://tailwindcss.com/docs/installation
但是下拉菜单应该是这样的
https://tailwindui.com/components/application-ui/elements/dropdowns
看起来还是垃圾
https://i.imgur.com/uViQHdu.png
我安装了Tailwind并使用init:
https://imgur.com/nGWspSt
我这样填写"tailwind.config.js":
- 顺风配置js**
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/components/DropdownVue/DropdownVue.vue"], <---INCLUDED DROPDOWN FILE
theme: {
extend: {},
},
plugins: [],
};
我创建了一个"index.css",并将Tailwind模块导入其中,如下所示:
- 索引. css**
@tailwind base;
@tailwind components; <-----INCLUDED IMPORTS
@tailwind utilities;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Noto Serif", serif, Ariel, Helvetica, sans-serif;
background: #d7d7d7;
}
img {
width: 100%;
object-fit: contain;
}
@import url("https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap");
我启动了构建过程并得到了一个"output.css"文件
https://i.imgur.com/mOKDwuc.png
我在我的"index.html"文件中包含了这样的内容:
<link href="/dist/output.css" rel="stylesheet">
在这一点上,你应该已经完成了,你的顺风组件应该按照那些说明工作。
但是,他们没有工作,然后我找到了一个更具体的页面安装Tailwind与Vue + Vite:
https://tailwindcss.com/docs/guides/vite
而且方向也差不多,只是它对NPM安装是这样说的:
npm install -D tailwindcss postcss autoprefixer
以前我只安装了"tailwindcss",所以我运行了其他2个软件包的安装,希望能修复它,但它没有。
我哪里说错了?谁能帮我修一下?
这是所有相关代码:
- 顺风配置js**
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/components/DropdownVue/DropdownVue.vue"], <---INCLUDED FILE
theme: {
extend: {},
},
plugins: [],
};
- 索引. css**
@tailwind base;
@tailwind components; <-----INCLUDED IMPORTS
@tailwind utilities;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Noto Serif", serif, Ariel, Helvetica, sans-serif;
background: #d7d7d7;
}
img {
width: 100%;
object-fit: contain;
}
@import url("https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap");
- 应用程序版本**
<template>
<NavBar :clicked="clicked" @toggleDrawer="toggleMenu()" />
<BackDrop :clicked="clicked" />
<SideDrawer :clicked="clicked" />
<router-view></router-view>
</template>
<style>
@import "./index.css"; <-------IMPORTED STYLES
</style>
- DropdownVue. vue(我尝试使用的TAILWIND组件)**
<template>
<Menu as="div" class="relative inline-block text-left">
<div>
<MenuButton
class="inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-100"
>
Options
<ChevronDownIcon class="-mr-1 ml-2 h-5 w-5" aria-hidden="true" />
</MenuButton>
</div>
<transition
enter-active-class="transition ease-out duration-100"
enter-from-class="transform opacity-0 scale-95"
enter-to-class="transform opacity-100 scale-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100 scale-100"
leave-to-class="transform opacity-0 scale-95"
>
<MenuItems
class="absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
>
<div class="py-1">
<MenuItem v-slot="{ active }">
<a
href="#"
:class="[
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
'block px-4 py-2 text-sm',
]"
>Account settings</a
>
</MenuItem>
<MenuItem v-slot="{ active }">
<a
href="#"
:class="[
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
'block px-4 py-2 text-sm',
]"
>Support</a
>
</MenuItem>
<MenuItem v-slot="{ active }">
<a
href="#"
:class="[
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
'block px-4 py-2 text-sm',
]"
>License</a
>
</MenuItem>
<form method="POST" action="#">
<MenuItem v-slot="{ active }">
<button
type="submit"
:class="[
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
'block w-full px-4 py-2 text-left text-sm',
]"
>
Sign out
</button>
</MenuItem>
</form>
</div>
</MenuItems>
</transition>
</Menu>
</template>
<script setup>
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
import { ChevronDownIcon } from "@heroicons/vue/20/solid";
</script>
1条答案
按热度按时间xjreopfe1#
tailwind.config.js
中的content
属性应为: