react-anted的运用
来源:互联网 发布:淘宝全场打折怎么设置 编辑:程序博客网 时间:2024/06/03 15:06
anted运用加载:参考资料https://ant.design/docs/react/introduce-cn
cnpm install --save antd
import {DatePicker} from 'antd'
样式加载两种方式:第一种
直接手动引入:import 'antd/dist/antd.css'
第二种在.babelrc文件中引入:
在引入下面的必须要加载:
cnpm install --save-dev babel-plugin-import
"plugins": [ ["import", { libraryName: "antd", style: "css" }] ]方能成功;
import {DatePicker,message } from 'antd'handleChange(date) { console.log(date) message.info('您选择的日期是: ' + date.toLocaleString()); this.setState({ date:date }); }render(){ return( <div className='mine'> 我来啦 <DatePicker onChange={value=>this.handleChange(value)} className='datePicker' /> <div>当前日期:{this.state.date.toString()}</div> <Hello/> </div> ) }}
button按钮的用法:
<div className="hello"> <Button type="primary" id='btn' loading={this.state.loading} onClick={this.enterLoading.bind(this)}>Primary</Button> <Button>Default</Button> <Button type="dashed" icon='search'></Button> <Button type="danger">Danger</Button> </div>详情参考antd官网API文档;https://ant.design/components/button-cn/
Icon图标的用法:
<Icon type="step-backward" spin='true' /><Icon type="step-forward" style={{ fontSize: 20, color: '#08c' }}/>详情API参考API文档:
https://ant.design/components/icon-cn/
栅格系统:24 栅格系统
<Row> <Col span={12}>24列栅格</Col> <Col span={12}>24列栅格</Col> </Row> <Row> <Col span={8}>col-8</Col> <Col span={8} offset={8}>col-8</Col> </Row> <Row> <Col span={6} offset={6}>col-6</Col> <Col span={6} offset={6}>col-6</Col> </Row> <Row> <Col span={18} push={6}>col-18 col-push-6</Col> <Col span={6} pull={18}>col-6 col-pull-18</Col> </Row> <Row type="flex" justify="start"> <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>
下拉菜单:
render(){ const menu = ( <Menu> <Menu.Item> <a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/">1st menu item</a> </Menu.Item> <Menu.Item> <a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/">2nd menu item</a> </Menu.Item> <Menu.Item> <a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/">3rd menu item</a> </Menu.Item> </Menu> ) return( <div className="hello"> <div> <Dropdown overlay={menu}> <a className="ant-dropdown-link" href="#"> Hover me <Icon type="down" /> </a> </Dropdown> </div> </div> ) }}
上传图片文件:
import { Upload, message, Button, Icon } from 'antd';class News extends Component{ render(){ const props = { name: 'file', action: '//jsonplaceholder.typicode.com/posts/', headers: { authorization: 'authorization-text', }, onChange(info) { if (info.file.status !== 'uploading') { console.log(info.file, info.fileList); } if (info.file.status === 'done') { message.success(`${info.file.name} file uploaded successfully`); } else if (info.file.status === 'error') { message.error(`${info.file.name} file upload failed.`); } }, }; return( <div className="hello"> <Upload {...props}> <Button> <Icon type="upload" /> Click to Upload </Button> </Upload> </div> ) }}
阅读全文
0 0
- react-anted的运用
- 关于react native运用的简单总结
- react-native中运用阿里的字体Iconfont(安卓)
- redux在react-native中的运用
- React学习之列表运用(七)
- react-app-redux项目中的运用
- <<、>>、>>>的运用
- "*"的运用
- React-native中灵活运用虚拟对象传递参数
- React-Native 开发(二) 在react-native 中 运用 redux
- 算术运用中除法的运用
- React&React-Native的实践的问题
- 运用你的Strut
- 验证码的运用
- 批处理的高级运用
- SESSIONBEAN 的运用
- 运用你的Strut
- js的运用
- PAT乙级1058 选择题
- 111
- IE7/8不兼容 js 的trim函数解析及解决方法
- 初学者都可以理解的dubbo项目解析
- 对于功能测试来说设计用例有哪些方法
- react-anted的运用
- PAT甲级 1060. Are They Equal (25)
- SSM框架
- shell脚本按天按周按月上传ODPS
- 性能测试之地铁模型分析(转)
- 69 个经典 Spring 面试题和答案 (超级经典)
- 【财富空间】AI淘金指南:不想成为最先死掉的那批?这是变身黄金矿工的秘籍
- 欢迎使用CSDN-markdown编辑器
- thyemleaf org.xml.sax.SAXParseException: 对实体 "*" 的引用必须以 ';' 分隔符结尾。