公共组件汇总

公共组件使用方法


弹窗BaseModel

<blockquote> <p>温馨提示:示例代码是tsx语法</p> <h2>先看下效果</h2> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/acae20de579c1b7e1a29d722071166af?showdoc=.jpg" alt="" /></p> </blockquote> <p>全屏展示,背景是灰色半透明。 源码:</p> <pre><code class="language-javascript">interface BaseModelState { visible: boolean; } @autobind export class BaseModel extends React.PureComponent&lt;BaseModelProps, BaseModelState&gt; { constructor(props: BaseModelProps) { super(props); this.state = { visible: false }; } async setVisible(visible: boolean) { await this.setState({ visible }); } render() { return (&lt;Modal visible={this.state.visible} transparent={true} onRequestClose={() =&gt; this.setVisible(false)}&gt; &lt;View style={styles.transparentBg}&gt; {this.props.children} &lt;/View&gt; &lt;/Modal&gt;); } }</code></pre> <p>用法: 可以先声明 -&gt; private baseModel?: BaseModel;</p> <pre><code class="language-javascript">&lt;BaseModel ref={(model: BaseModel) =&gt; this.baseModel = model}&gt; &lt;View style={styles.whiteBg}&gt; &lt;Text style={styles.comfirmTitle}&gt;提示&lt;/Text&gt; &lt;Text style={styles.confirmDesript}&gt;确定要申请调档吗?注意,申请调档成功后,当年不可再进行申请。&lt;/Text&gt; &lt;View style={{ flexDirection: 'row' }}&gt; &lt;TouchImageWithText textStyle={styles.confirmBtnText} text={'确定'} activeOpacity={1} touchStyle={{ flex: 1, height: 50 }} onPress={() =&gt; { this.setModelVisible(false); this.props.confirm &amp;&amp; this.props.confirm(); }} /&gt; &lt;View style={styles.confirmMidLine} /&gt; &lt;TouchImageWithText textStyle={styles.confirmBtnText} text={'取消'} activeOpacity={1} touchStyle={{ flex: 1, height: 50 }} onPress={() =&gt; this.setModelVisible(false)} /&gt; &lt;/View&gt; &lt;/View&gt; &lt;/BaseModel&gt;</code></pre>

页面列表

ITEM_HTML