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/

相关推荐
2603_965896621 分钟前
CSS BEM 命名规范|组件化样式分层权威指南
前端·javascript·css
进击的明明2 分钟前
前端开发中的 BEM 国际命名规范:让 CSS 不再"打架"
前端·css·html
deli0076 分钟前
中文在网址里为什么变成 E4B8AD?URL 编码 22 组用例实测
前端
yuniko-n8 分钟前
【JUC】内存屏障
java·开发语言
羲云11 分钟前
MOSS-Image 开源后爆火:5B 生图模型真正值得关注的,是可控排版
前端
Linux运维技术栈11 分钟前
近期 PHP 高危安全风险排查与多环境升级实操
开发语言·安全·php
BreezeJiang20 分钟前
闭包和 useState 是两个知识点?你可能只学了半条作用域链
前端·面试
2601_9583529030 分钟前
一款模块通吃15类语音产品?AN-93如何实现录音笔、门禁、IPC的快速适配
前端·人工智能·嵌入式硬件·回声消除·降噪处理
Fnetlink132 分钟前
Fnet 云网安 261023
运维·开发语言·网络·人工智能·安全·web安全·php
子兮曰32 分钟前
Bun v1.4.4 实测:2,025 个文件,bun fmt 2.6 秒跑完
前端·后端·bun