npm install --save antd
,安装antd。App.js中引入antd的样式文件,引入antd的Button组件。
import React, { Component } from 'react'
import { Button } from 'antd';
// import 'antd/dist/antd.css';
import 'antd/dist/antd.min.css'
export default class App extends Component {
render() {
return (
<div>
<button>点我</button>
<Button type="primary">按钮1</Button>
<Button type="default">按钮2</Button>
<Button type="link">按钮4</Button>
</div>
)
}
}
App.js从antd的子库导入antd的css文件:
antd/dist/antd.css
时,npm start
启动应用时遇到如下警告:
Failed to parse source map: ‘webpack://antd/./components/time-picker/style/index.less’ URL is not supported
所以改用了antd/dist/antd.min.css
。
@ant-design/icons
中引入图标组件,如微信图标、微博图标。
import React, { Component } from 'react'
import { Button } from 'antd';
import {WechatOutlined,WeiboOutlined} from '@ant-design/icons'
import 'antd/dist/antd.min.css'
export default class App extends Component {
render() {
return (
<div>
<button>点我</button>
<Button type="primary">按钮1</Button>
<Button type="default">按钮2</Button>
<Button type="link">按钮4</Button>
<WechatOutlined />
<WeiboOutlined />
</div>
)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)