cn.ts 440 B

12345678910111213141516
  1. import { clsx, type ClassValue } from 'clsx'
  2. // @ts-ignore
  3. import { create } from '@weapp-tailwindcss/merge/v4';
  4. import Taro from '@tarojs/taro';
  5. // 根据当前环境判断是否需要转义
  6. const isWeapp = Taro.getEnv() === Taro.ENV_TYPE.WEAPP;
  7. const { twMerge } = create({
  8. // 仅在小程序环境下启用转义,H5环境禁用
  9. disableEscape: !isWeapp
  10. });
  11. export function cn(...inputs: ClassValue[]) {
  12. return twMerge(inputs)
  13. }