ant-design 实现 添加页面
2024-09-27 06:32:56
1.逻辑代码
/**
* 添加用户
*/
import React,{PureComponent} from 'react'
import {Card,Form,Input,Select,Button} from 'antd'
import {connect} from 'react-redux' /**
* 用户列表
*/ const FormItem = Form.Item; const Option = Select.Option; @Form.create()
class UserAdd extends PureComponent{
// 生命周期--组件加载完毕
componentDidMount(){
// this.props.changetitle("用户管理—添加")
} render(){
const { getFieldDecorator } = this.props.form; const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 7 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 12 },
md: { span: 10 },
},
}; const submitFormLayout = {
wrapperCol: {
xs: { span: 24, offset: 0 },
sm: { span: 10, offset: 7 },
},
}; return(
<Card bordered={false}>
<Form layout="horizontal">
{/*账号*/}
<FormItem {...formItemLayout} label="账号">
{getFieldDecorator('account', {
rules: [{
required: true, message: '请输入账号',
}],
})(
<Input placeholder="请输入账号" />
)}
</FormItem>
{/*姓名*/}
<FormItem {...formItemLayout} label="姓名">
{getFieldDecorator('name', {
rules: [{
required: true, message: '请输入姓名',
}],
})(
<Input placeholder="请输入姓名" />
)}
</FormItem>
{/*状态*/}
<FormItem {...formItemLayout} label="状态">
{getFieldDecorator('state', {
rules: [{
required: true, message: '请选择状态',
}],
initialValue:"0",
})(
<Select >
<Option value="0">禁用</Option>
<Option value="1">启用</Option>
</Select>
)}
</FormItem>
{/*提交|保存按钮*/}
<FormItem {...submitFormLayout} style={{ marginTop: 32 }}>
<Button type="primary" htmlType="submit" >
提交
</Button>
<Button style={{ marginLeft: 8 }}>保存</Button>
</FormItem>
</Form>
</Card>
)
}
} export default connect ((state)=>(
{
state
}
))(UserAdd)
2.效果图
最新文章
- currentColor-CSS3非常有用的变量
- oracle里面base64加解密
- permutation II (boss出来了)
- AOP 学习笔记
- 无法获取有关Windows NT 组\用户‘组\用户’的信息,错误代码0x5(Microsoft SQL Server,错误:15404)
- Linux下编译使用boost库:
- 普通用户登录Oracle DB Control
- Linux C/C++编译环境搭建
- spring 内部工作机制(一)
- Java异常处理认识
- 机器学习技法:14 Radial Basis Function Network
- 第六课 Html5常用标签 html5学习1
- BUAA_OO第一单元作业总结
- 第57节:Java中流的操作以及编码解码
- 查看是否存在tomcat进程和关闭方法
- Linux查看GPU使用情况
- as3 连接mysql
- [RGEOS]数学基础
- Think in Java笔记——Java与对象
- mybatis 需要注意的点 MyBatis 插入空值时,需要指定JdbcType (201
热门文章
- hdu5079
- Python timedelta模块 时间增减用法
- (转帖)关于easyui中的datagrid在加载数据时候报错:无法获取属性";Length";的值,对象为null或未定义
- (转) C#解惑:HashSet<;T>;类
- AtCoder - 2061 Tree Restoring
- 【费马小定理】HDU4704-Sum
- 微服务之SpringCloud实战(五):SpringCloud Eureka详解
- c++基础类型之signed、unsigned的一个细节
- 【R笔记】R语言利器之ddply
- 将html文档转成pdf