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/

相关推荐
程序员鱼皮3 分钟前
格局!刚刚 DeepSeek 正式开放全家桶 API,咱都能复刻 DeepSeek App 了?
前端·aigc·ai编程
ZhengEnCi17 分钟前
登录页电脑端怎么设计才不空:5 种布局方案与可粘贴 AI 提示词
前端·css·设计
Penge66617 分钟前
JavaScript:DOM 树
前端
用户00447295382523 分钟前
练歌镜:让眼镜听懂“循环这一句”
javascript
Penge66633 分钟前
CSS 核心布局指南:盒模型、Flex 布局与 Position 定位
前端
Penge6662 小时前
HTML基础:HTML 标签属性
前端
Penge6662 小时前
HTML 基础:块级元素、行内元素与行内块元素详解
前端
Penge6662 小时前
前端基础:html语义化
前端
用户30816998764853 小时前
同一个端口能被两个程序监听吗?TCP 11 组绑定实测
前端
deli0073 小时前
红绿灯配时实测:固定 60 秒 vs 自适应,2400 辆车差多少
前端