javascript - react中引入antd 为甚么没有样式?

根据官网(https://ant.design/docs/react/introduce-cn)
可知:
引入样式有几种方式
1.手动引入
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'

import DatePicker from 'antd/lib/date-picker';  // 加载 JS
import 'antd/lib/date-picker/style/css';        // 加载 CSS
// import 'antd/lib/date-picker/style';         // 加载 LESS

2.按需加载,使用 babel-plugin-import(推荐)

// .babelrc or babel-loader option
{
  "plugins": [
    ["import", { libraryName: "antd", style: "css" }] // `style: true` 会加载 less 文件
  ]
}

然后只需从 antd 引入模块即可,无需单独引入样式。等同于下面手动引入的方式。

// babel-plugin-import 会帮助你加载 JS 和 CSS
import { DatePicker } from 'antd';

posted @ 2017-03-25 17:05  Sameen  阅读(1728)  评论(0)    收藏  举报