vue中使用tailwindcss

Tailwind CSS with Vue

tailwindcss官方文档

创建Vue项目

sh 复制代码
npm create vite@latest my-project -- --template vue
cd my-project

安装Tailwind CSS,创建tailwind.config.jspostcss.config.js

sh 复制代码
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

配置tailwind.config.js

js 复制代码
/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

添加Tailwind指令到全局css文件中,此处文件地址比如在./src/style.css

css 复制代码
@tailwind base;
@tailwind components;
@tailwind utilities;

main.js入口引入style.css

js 复制代码
import { createApp } from 'vue'
import './style.css'

启动项目

sh 复制代码
npm run dev

在模板中使用tailwindcss

vue 复制代码
<template>
  <h1 class="text-3xl font-bold underline">
    Hello world!
  </h1>
</template>

可以看到页面上此时已经有效果了。

具体使用教程可以查看官方文档。

相关推荐
蜚鸣8 小时前
Vue的快速入门
vue
ice breaker17 小时前
tailwindcss 究竟比 unocss 快多少?
css·unocss·tailwindcss
吃饭最爱1 天前
⽹络请求Axios的概念和作用
vue
魂尾ac2 天前
Django + Vue3 前后端分离技术实现自动化测试平台从零到有系列 <第一章> 之 注册登录实现
后端·python·django·vue
是罐装可乐2 天前
深入理解 Vue3 Router:三种路由模式的工作原理与实战应用
架构·vue·路由·history·hash·ssr·router
老华带你飞2 天前
租房平台|租房管理平台小程序系统|基于java的租房系统 设计与实现(源码+数据库+文档)
java·数据库·小程序·vue·论文·毕设·租房系统管理平台
zhz52143 天前
Spring Boot + Redis 缓存性能优化实战:从5秒到毫秒级的性能提升
java·spring boot·redis·缓存·vue
小胖墩有点瘦3 天前
【基于协同过滤的校园二手交易平台】
java·vue·毕业设计·springboot·计算机毕业设计·协同过滤·校园二手交易平台
小圣贤君3 天前
小说创作中的时间轴体验设计:事序图交互与用户体验优化
electron·vue·甘特图·时序图·写作软件
知识分享小能手4 天前
React学习教程,从入门到精通,React 构造函数(Constructor)完整语法知识点与案例详解(16)
前端·javascript·学习·react.js·架构·前端框架·vue