簡體   English   中英

如何獲取順風 CSS 2 的默認配置

[英]How to get default config of tailwind CSS 2

順風 CSS 2.x

我想獲取height配置的默認高度值。

const defaultConfig = require('tailwindcss/defaultConfig');
const height = defaultConfig.theme.height;

但是高度是 function,正如在源代碼中所見:

// tailwindcss/stubs/defaultConfig.stub.js
module.exports = {
  // ...
  theme: {
    // ...
    height: (theme) => ({
      auto: 'auto',
      ...theme('spacing'),
      '1/2': '50%',
      '1/3': '33.333333%',
    }),
  },
};

我理解代碼:傳遞了一個theme function ,然后調用它來獲取主題的其他配置部分。

但我不知道這個 function 是什么以及在哪里可以找到它,所以我可以將它導入到我的配置中並將其傳遞為:

defaultConfig.theme.height(thisIsTheFunctionInQuestion)

我在哪里可以找到它?

為了解決任何順風配置 object,使用resolveConfig()輔助方法

import resolveConfig from 'tailwindcss/resolveConfig'
import defaultConfig from 'tailwindcss/defaultConfig'

const config = resolveConfig(defaultConfig)

console.log(config.theme.height) // will return object

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM