Tailwind css系列教程(三)

vue3环境搭建Tailwind CSS

1、创建vue3项目

创建项目:npm create vite@latest vue3app01 --template vue

进入项目文件夹:cd vue3app01

加载默认库:npm install

测试运行:npm run dev

2、搭建tailwind css

(1)引入 Tailwind

复制代码
npm install -D tailwindcss postcss autoprefixer

(2)创建用于初始化 Tailwind 的配置文件------生成 tailwind.config.js、postcss.config.js

复制代码
npx tailwindcss init -p

修改 tailwind.config.js

复制代码
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}",
    "./node_modules/flowbite/**/*.js"
  ],
  theme: {
    extend: {},
  },
  plugins: [
    require('flowbite/plugin'),
  ],
  corePlugins: {
    // 取消 tailwindcss 的默认样式
    preflight: false
  }
}

(3)编写css文件,路径自定义

src\assets\main.css

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

(4)main.js引入

复制代码
import './assets/main.css'

(5)vue测试

src/comptents/helloword.vue

复制代码
<template>
  <div class="w-32 h-32 bg-blue-500">
    hello
  </div>
  <h1 class="text-3xl text-red-500">Tailwind CSS</h1>
</template>

效果

相关推荐
清晨Coding1 小时前
为什么用 React Developer Tools 查看组件树这么乱?
前端·react.js
鶴哥只手遮天1 小时前
《Electron 45.2.3 内核解剖》第 4 章 补丁体系:380 个补丁改了什么
前端·electron
FungLeo3 小时前
成为全栈·Vue 管理后台篇·分类树与标签管理:层级数据如何落到管理界面
前端·javascript·vue.js·分类树·naive ui·标签管理·前端数据结构
Lank_M7 小时前
白底都占八成,PNG 为何只在图表页赢过 JPG
前端
张一凡937 小时前
给 Coding Agent 加一道"架构闸门":Jin 是如何做到"先审架构、再写代码、不漂移"的
前端·后端·agent
Linye7 小时前
AI 写的 HTML 原型全是空壳?聊聊真实 DOM 交互避坑
前端·人工智能
ZANE7 小时前
纯前端实现的 PDF 与图片互相转换工具技术实现
前端
Swot7 小时前
SvelteKit Remote Functions 使用指南
前端·后端
Cooper257 小时前
三源热榜去重加 AI 摘要:URL 唯一键踩出的三个坑
前端·python
Yk酱228408 小时前
A2UI探索随笔-技术选型
前端