当前位置 博文首页 > Jet_Lover的博客:关于引入antd样式不生效的问题

    Jet_Lover的博客:关于引入antd样式不生效的问题

    作者:[db:作者] 时间:2021-07-05 13:06

    有时候我们在引入antd,依赖包什么的都下好了的,可是样式就是不生效,比如这样

          import { Row, Col,Button } from 'antd';
          <Row justify="space-between">
                        <Col span={4}>col-4</Col>
                        <Col span={4}>col-4</Col>
                        <Col span={4}>col-4</Col>
                        <Col span={4}>col-4</Col>
                    </Row>
                    <Button type="dashed">登陆</Button>
    

    然后页面运行结果却是这样的
    在这里插入图片描述
    这完全没有效果啊,明明我 npm i antd cnpm i antd npm add antd都试过了,为啥没有效果呢,
    在这里插入图片描述
    然后看到官网有这么一句话
    在这里插入图片描述
    就是

    @import '~antd/dist/antd.css';
    

    然后我也在index.css文件里面引入了,结果直接报错???

    ======================================
    又找了一会,发现没有下载依赖包。
    于是把这个下下来就好啦!

    npm i babel-plugin-import
    

    最后看效果图
    在这里插入图片描述
    这样就可以啦~

    cs