Welink React-ui表单组件Form(文本域)

举报
云会议运营喵大人 发表于 2020/02/21 18:00:01 2020/02/21
【摘要】 Form(文本域)填写类表单-文本域。Form UI 提供与WeLink规范一致的表单视图。参数说明InputItem名称类型默认值说明typestring规定 input 元素的类型disabledboolfalse是否禁用placeholderstring可描述输入字段预期值的提示信息valuestring可配和onChange事件,通过设置状态改变显示值onChangefunc文本值改...

Form(文本域)


填写类表单-文本域。Form UI 提供与WeLink规范一致的表单视图。

参数说明

InputItem

名称类型默认值说明
typestring
规定 input 元素的类型
disabledboolfalse是否禁用
placeholderstring
可描述输入字段预期值的提示信息
valuestring
可配和onChange事件,通过设置状态改变显示值
onChangefunc
文本值改变时触发

import React from 'react';
import {
  CellBody, TextArea, Tags,
  Form, FormCell, FormHeader,
  FormItem, InputItem
} from '@wecode/react-weui';

const _marginTop = { marginTop: 30 };
export default class FormWrite extends React.Component {

  state={
    value: '',
    text1: '',
    text2: ''
  }

  handleChangeValue = (key, value) => {
    this.setState({ [key]: value });
  }

  render() {
    const { value, text1, text2 } = this.state;
    return (
      <section>
        <Form form>
          <FormItem>
            <InputItem type="text" placeholder="请输入" value={value} onChange={text=>this.handleChangeValue('value', text)} />
          </FormItem>
        </Form>

        <Form style={_marginTop} form>
          <FormItem>
            <FormHeader label>标题</FormHeader>
            <FormCell>
              <CellBody>
                <TextArea placeholder="Enter your comments" rows="3" showCounter maxLength={300} />
              </CellBody>
            </FormCell>
          </FormItem>
        </Form>

        <Form style={_marginTop} form>
          <FormItem>
            <FormCell>
              <CellBody>
                <TextArea placeholder="Enter your comments" rows="3" showCounter maxLength={300} />
              </CellBody>
            </FormCell>
          </FormItem>
        </Form>

        <Form style={_marginTop} form>
          <FormItem>
            <FormHeader label>标题</FormHeader>
            <Tags
              tags={['常用', '常用', '常用三', '常用四字', '常用五个字']}
              onChange={(e, text)=>{
                const value = text1 + text;
                if (value.length <= 300) {
                  this.handleChangeValue('text1', value);                       
                }
              }}
            />
            <FormCell>
              <CellBody>
                <TextArea
                  placeholder="Enter your comments"
                  rows="3"
                  showCounter
                  maxLength={300}
                  value={text1}
                  onChange={(e)=>{
                    const text = e.target.value;
                    if (text.length <= 300) {
                      this.handleChangeValue('text1', text);                       
                    }
                  }}
                />
              </CellBody>
            </FormCell>
          </FormItem>
        </Form>

        <Form style={_marginTop} form>
          <FormItem>
            <Tags
              tags={['常用', '常用', '常用三', '常用四字', '常用五个字']}
              onChange={(e, text)=>{
                const value = text2 + text;
                if (value.length <= 300) {
                  this.handleChangeValue('text2', value);                       
                }
              }}
            />
            <FormCell>
              <CellBody>
                <TextArea
                  placeholder="Enter your comments"
                  rows="3"
                  showCounter
                  maxLength={300}
                  value={text2}
                  onChange={(e)=>{
                    const text = e.target.value;
                    if (text.length <= 300) {
                      this.handleChangeValue('text2', text);                       
                    }
                  }}
                />
              </CellBody>
            </FormCell>
          </FormItem>
        </Form>
      </section>
    );
  }
}


【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。