ant-design / antd-style

css-in-js library with antd v5 token system
https://ant-design.github.io/antd-style/
MIT License
189 stars 29 forks source link

为什么我这么写没起作用, 哪里写错了? #31

Closed Shen-Shuyi closed 1 year ago

Shen-Shuyi commented 1 year ago

🧐 问题描述

写了一段测试代码, 但是为什么字没有变红?

import React, { useEffect, useRef, useState } from 'react'

import { Layout, Menu, Button } from 'antd';

// style
import { createStyles, css } from 'antd-style'
const useStyles = createStyles({
    head: css`
        color: 'red';
    `
})
// style

const { Content, Sider, Header } = Layout;

export default function MyLayout() {
    const { styles } = useStyles();
    return (
        <Layout>
            <Layout>
                <Sider theme='light'>
                    aaaaa
                </Sider>
                <Layout>
                    <div ><b className={styles.head} >123</b></div>
                    <Content style={{minHeight: '100%', backgroundColor: '#fff'}}>
                        <Button type="primary">11</Button>
                    </Content>
                </Layout>
            </Layout>
        </Layout>
    )
}

123始终是黑色, 打开控制台这个样式是不起作用的 image

🚑 其他信息

Shen-Shuyi commented 1 year ago

解决了, red不应该加单引号