From 1ecb54583c6bad3f0c982fca626113567fe68a3f Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Mon, 19 May 2025 17:26:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=85=B3=E4=BA=8E?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20TailwindCSS=20=E7=9A=84=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/base/4-style2.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/base/4-style2.md diff --git a/docs/base/4-style2.md b/docs/base/4-style2.md new file mode 100644 index 0000000..99ea1a5 --- /dev/null +++ b/docs/base/4-style2.md @@ -0,0 +1,41 @@ +# 关于使用 TailwindCSS + +对于 unibest 项目使用 TailwindCSS 的评估如下: + +1. **直接使用TailwindCSS的限制**: + + - 原生TailwindCSS是为Web设计的,在小程序环境下会有兼容性问题 + - 不支持rpx单位,在小程序适配上有困难 + - 需要额外配置postcss和purgeCSS才能在小程序工作 + +2. **当前UnoCSS的优势**: + + - 您的项目已经配置了`unocss-applet`,专门为小程序优化 + - 支持rpx单位转换(通过presetRemRpx) + - 支持小程序属性化写法(transformerAttributify) + - 体积更小,按需生成样式 + +3. **替代方案建议**: + + - 保持使用UnoCSS,它已经实现了Tailwind的大部分功能 + - 可以通过安装`@unocss/preset-wind`来获得Tailwind风格的类名: + + ```bash + pnpm add -D @unocss/preset-wind + ``` + + 然后在uno.config.ts中添加: + + ```typescript + import { presetWind } from '@unocss/preset-wind' + + export default defineConfig({ + presets: [ + presetWind(), + // 其他presets... + ], + }) + ``` + +4. **结论**: + 在uni-app项目中,UnoCSS是比原生TailwindCSS更合适的选择,特别是针对小程序开发。通过`preset-wind`可以获得类似Tailwind的开发体验。