vue3使用tailwindcss报错问题

  1. npm create vite@latest

  2. npm install -D tailwindcss postcss autoprefixer

  3. npx tailwindcss init
    4. ·不过执行 npx tailwindcss init 的时候控制台就报错了

    js 复制代码
    PS E:\vite-demo> npx tailwindcss init
    npm ERR! cb.apply is not a function
    npm ERR! A complete log of this run can be found in:
    1. 那就手动创建 tailwind.config.js文件和postcss.config.js文件
    js 复制代码
    	// tailwind.config.js
    	/** @type {import('tailwindcss').Config} */
    	module.exports = {
    	  content: ["./src/**/*.{html,js}"],
    	  theme: {
    	    extend: {},
    	  },
    	  plugins: [],
    	}
    js 复制代码
    // postcss.config.js
    module.exports = {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      }
    }

    然后再style.css引入

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

    npm install
    报错

    js 复制代码
    [vite] Internal server error: [postcss] It looks like you're trying to use
    `tailwindcss` directly as a PostCSS plugin.The PostCSS plugin has
    moved to a separate package, so to continue using Tailwind CSS with PostCSS
    you'll need to install `@tailwindcss/postcss` and update your PostCSS configuration.
  4. 重新安装 npm install @tailwindcss/postcss

js 复制代码
	import postcssTailwind from '@tailwindcss/postcss'; 
		import autoprefixer from 'autoprefixer'; 
		export default { 
		    plugins: [ postcssTailwind, autoprefixer ]
		};

注意: 要看清版本 现在安装的tailwindcss 是4.x 官网是3.x

地址:https://tailwindcss.com/

相关推荐
泓博8 分钟前
Objective-c把字符解析成字典
开发语言·ios·objective-c
try2find11 分钟前
安装llama-cpp-python踩坑记
开发语言·python·llama
青皮桔20 分钟前
CSS实现百分比水柱图
前端·css
失落的多巴胺20 分钟前
使用deepseek制作“喝什么奶茶”随机抽签小网页
javascript·css·css3·html5
DataGear23 分钟前
如何在DataGear 5.4.1 中快速制作SQL服务端分页的数据表格看板
javascript·数据库·sql·信息可视化·数据分析·echarts·数据可视化
影子信息25 分钟前
vue 前端动态导入文件 import.meta.glob
前端·javascript·vue.js
青阳流月26 分钟前
1.vue权衡的艺术
前端·vue.js·开源
RunsenLIu28 分钟前
基于Vue.js + Node.js + MySQL实现的图书销售管理系统
vue.js·mysql·node.js
样子201830 分钟前
Vue3 之dialog弹框简单制作
前端·javascript·vue.js·前端框架·ecmascript
kevin_水滴石穿31 分钟前
Vue 中报错 TypeError: crypto$2.getRandomValues is not a function
前端·javascript·vue.js