美文网首页
React 样式模块化

React 样式模块化

作者: _Wake | 来源:发表于2017-03-17 15:21 被阅读142次
  1. 依赖模块
    "babel-plugin-react-html-attrs": "^2.0.0",
    "style-loader": "^0.13.1",
    "css-loader": "^0.25.0"
  1. webpack.config.js 配置文件
      // 下面是添加的 css 的 loader , 也即是 css 模块化的配置方法
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]'
      }
  1. 导入CSS
var footerCss = require("../../footer.css")
<footer className={footerCss.miniFooter}>
  1. JSX 与 CSS的互转
    转换工具 : http://staxmanade.com/CssToReact/

  2. Ant Design 样式框架

// 安装
npm install antd --save
// 引入样式
import 'antd/dist/antd.css';
// 引入组件
import { Input, Select, Icon } from 'antd';

// 使用组件
<Input placeholder="Basic usage" />

相关文章

网友评论

      本文标题:React 样式模块化

      本文链接:https://www.haomeiwen.com/subject/mezsnttx.html