Skip to content
Discussion options

You must be logged in to vote

其实这个现在就支持,因为 tailwindcss 实际上是可以多上下文的,详见 https://tailwindcss.com/docs/functions-and-directives#config

所以使用 @config 就简单了,你创建一个额外的 tailwind.config.js 文件,用来创建额外的上下文:

const path = require('path')

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [path.resolve(__dirname, "./TailwindPrefix.tsx")],
  prefix: 'my-',
  corePlugins: {
    preflight: false
  }
}

然后创建一个额外的 scss :

@config "./tailwind.config.js";

// @tailwind base;
// @tailwind components;
@tailwind utilities;

然后这个目录下面,你有一个组件 TailwindPrefix.tsx:

import React from "react";
import { View } from '@tarojs/components'
import './TailwindPrefix.scss'

export const TailwindPrefix: React.FC = () => {
  return <View clas…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sonofmagic
Comment options

You must be logged in to vote
2 replies
@sonofmagic
Comment options

@yuuk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants