MCPcopy Create free account
hub / github.com/Lobos/react-ui / render

Method render

docs/src/js/pages/modal.jsx:47–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 }
46
47 render () {
48 return (
49 <div>
50 <div className="header">
51 <h1>Modal</h1>
52 <h2>对话框</h2>
53 </div>
54
55 <div className="content">
56 <Code>
57{`<Modal
58 clickaway: {bool}, // 为 true 时,点击页面空白部分关闭Modal,默认值为 false
59 width={700} // 宽度,默认值为 500
60 header={string|element} // 标题,值为 string 或者 ReactElement,可为空
61 isOpen={bool} // 是否打开
62 onClose={function} // 关闭Modal时触发
63 buttons: {
64 {text}: func|string // text 为按钮文字,func 返回 true 或者值为 true,关闭 Modal
65 // func 可以设置为string,当func === 'submit' 时,会触发children下的form的submit事件
66 }
67>
68 {children} // 内容,任意对象
69</Modal>
70`}
71 </Code>
72
73 <Example>
74<Modal width={700} header="一个弹出表单"
75 isOpen={this.state.modalIsOpen}
76 onClose={() => this.setState({ modalIsOpen: false })}
77 buttons={{
78 '确定': 'submit',
79 '取消': true
80 }}>
81 <div>
82 <Form onSubmit={
83 (data) => {
84 alert(JSON.stringify(data));
85 this.setState({ modalIsOpen: false })
86 }} layout="aligned">
87 <FormControl name="name" grid={7/8} required={true} label="姓名" type="text" />
88 <FormControl name="birthday" required={true} label="生日" type="date" />
89 <FormControl name="description" grid={7/8} label="简介" type="textarea" rows={6} />
90 </Form>
91 </div>
92</Modal>
93<Button status="primary" onClick={ () => this.setState({ modalIsOpen: true }) }>open form</Button>
94 </Example>
95
96 <div><em>Modal</em> Modal提供了一个静态方法,供任意位置调用。open会返回一个id,供close调用</div>
97 <h2 className="subhead">Modal.open(options)</h2>
98 <Code>
99{`options = {
100 clickaway: {bool}, // 为 true 时,点击页面空白部分关闭Modal,默认值为 false
101 header: {string|element}, // 标题,值为 string 或者 ReactElement,可为空
102 content: {string|element}, // 内容,值为 string 或者 ReactElement,必填
103 width: {int|string}, // 宽度,默认值为 500
104 onClose: function, // 当Modal关闭时触发

Callers

nothing calls this directly

Calls 2

openMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected