Ashun's 技術駅 Ashun's 技術駅
首页
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • Vue
  • 现代web布局
  • React
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 技术资源
  • 第一阶段

    • HTML
  • 第二阶段

    • JavaScript
  • 第三阶段

    • Vue
  • 第四阶段

    • 实战项目
  • 每周测试

    • 每周
  • 其他

    • Vue引入UI框架
    • Web前端面试
    • Vue3-resource
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 福利资源
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Ashun

前端界的小学生
首页
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • Vue
  • 现代web布局
  • React
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 技术资源
  • 第一阶段

    • HTML
  • 第二阶段

    • JavaScript
  • 第三阶段

    • Vue
  • 第四阶段

    • 实战项目
  • 每周测试

    • 每周
  • 其他

    • Vue引入UI框架
    • Web前端面试
    • Vue3-resource
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 福利资源
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Vue3-UI框架

  • Vue3-CSS库

    • 01Vue3引入tailwindcss版本2
      • 定制自己的Tailwind CSS
  • 《Vue引入UI框架》
  • Vue3-CSS库
xugaoyi
2022-03-03
目录

01Vue3引入tailwindcss版本2

# Vue3 引入 tailwindcss 版本 2

地址:tailwindcss (opens new window)

安装tailwindcss库

npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat "postcss@^7" "autoprefixer@^9"

# yarn add vue-loader-v16
1
2
3
  • 新建tailwind.config.js
  • 新建postcss.config.js
npx tailwindcss init -p
1

代码

// tailwind.config.js
module.exports = {
  purge: ["./src/**/*.html", "./src/**/*.vue", "./src/**/*.jsx"],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [],
};
1
2
3
4
5
6
7
8
9
10
11
12
//postcss.config.js
module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};
1
2
3
4
5
6
7

新建tailwind.css文件

/* src/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
1
2
3
4

引入main.js

import "./tailwind.css";
1

测试使用

<!-- src/App.vue -->
<template>
  <div class=" bg-red-600 h-screen"></div>
</template>
1
2
3
4

启动项目

npm run serve
# 或
yarn serve
1
2
3

# 定制自己的Tailwind CSS

// fontSize
    komabig: ['10rem', { lineHeight: '10rem' }],
...
// 定制一个新的主题
theme: {
    extend: {
      colors: {
        bootstrap_primary: '#0d6efd',
        bootstrap_secondary: '#6c757d',
        bootstrap_success: '#198754',
        bootstrap_danger: '#dc3545',
        bootstrap_info: '#0dcaf0',
      }
    },
1
2
3
4
5
6
7
8
9
10
11
12
13
14

App.vue

<div class="text-komabig">小马大字体</div>
<div class="bg-bootstrap_primary text-white">像我么</div>
<div class="bg-bootstrap_success text-white">像我么</div>
<div class="bg-bootstrap_danger text-white">像我么</div>
1
2
3
4
  • 打包如何出现空白就添加以下代码
//vue.config.js
module.exports = {
  publicPath: "./",
};
1
2
3
4
编辑 (opens new window)
上次更新: 2023/08/06, 00:38:41
02Vue引入Bootstrap4

← 02Vue引入Bootstrap4

最近更新
01
课件-react路由-V6
01-22
02
课件-国际化
01-22
03
课件-redux-toolkit
01-22
更多文章>
Theme by Vdoing | Copyright © 2019-2024 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式