返回介绍

Ionic4 组件 ion-textarea

发布于 2019-11-22 18:04:17 字数 11762 浏览 1371 评论 0 收藏 0

Ionic4项目中我们可以使用Ionic4组件ion-textarea对项目进行布局。

ion-textarea官方文档地址:https://ionicframework.com/docs/api/textarea

The textarea component is used for multi-line text input. A native textarea element is rendered inside of the component. The user experience and interactivity of the textarea component is improved by having control over the native textarea.

Unlike the native textarea element, the Ionic textarea does not support loading its value from the inner content. The textarea value should be set in the value attribute.

The textarea component accepts the native textarea attributes in addition to the Ionic properties.

ion-textarea 用法(Usage)






  




  Description
  




  Summary
  
  




  Comment
  




  Notes
  
</ion-item>





  




  Description
  




  Summary
  
  




  Comment
  




  Notes
  
</ion-item>
import React from 'react';

import { IonTextarea, IonItem, IonLabel } from '@ionic/react';

const Example: React.SFC = () => (
  
    {/*-- Default textarea --*/}
    

    {/*-- Textarea in an item with a placeholder --*/}
    
      
    

    {/*-- Textarea in an item with a floating label --*/}
    
      Description
      
    

    {/*-- Disabled and readonly textarea in an item with a stacked label --*/}
    
      Summary
      
      
    

    {/*-- Textarea that clears the value on edit --*/}
    
      Comment
      
    

    {/*-- Textarea with custom number of rows and cols --*/}
    
      Notes
      
    
  
);

export default Example;

  
  

  
  
    
  

  
  
    Description
    
  

  
  
    Summary
    
    
  

  
  
    Comment
    
  

  
  
    Notes
    
  
</template>

ion-textarea 属性(Properties)

autoGrow

Description

If true, the element height will increase based on the value.

Attributeauto-grow
Typeboolean
Defaultfalse

autocapitalize

Description

Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.

Attributeautocapitalize
Typestring
Default'none'

autofocus

Description

This Boolean attribute lets you specify that a form control should have input focus when the page loads.

Attributeautofocus
Typeboolean
Defaultfalse

clearOnEdit

Description

If true, the value will be cleared after focus upon edit. Defaults to true when type is "password", false for all other types.

Attributeclear-on-edit
Typeboolean
Defaultfalse

color

Description

The color to use from your application's color palette. Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark". For more information on colors, see theming.

Attributecolor
Typestring | undefined

cols

Description

The visible width of the text control, in average character widths. If it is specified, it must be a positive integer.

Attributecols
Typenumber | undefined

debounce

Description

Set the amount of time, in milliseconds, to wait to trigger the ionChange event after each keystroke.

Attributedebounce
Typenumber
Default0

disabled

Description

If true, the user cannot interact with the textarea.

Attributedisabled
Typeboolean
Defaultfalse

maxlength

Description

If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters that the user can enter.

Attributemaxlength
Typenumber | undefined

minlength

Description

If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters that the user can enter.

Attributeminlength
Typenumber | undefined

mode

Description

The mode determines which platform styles to use.

Attributemode
Type"ios" | "md"

name

Description

The name of the control, which is submitted with the form data.

Attributename
Typestring
Defaultthis.inputId

placeholder

Description

Instructional text that shows before the input has a value.

Attributeplaceholder
Typenull | string | undefined

readonly

Description

If true, the user cannot modify the value.

Attributereadonly
Typeboolean
Defaultfalse

required

Description

If true, the user must fill in a value before submitting a form.

Attributerequired
Typeboolean
Defaultfalse

rows

Description

The number of visible text lines for the control.

Attributerows
Typenumber | undefined

spellcheck

Description

If true, the element will have its spelling and grammar checked.

Attributespellcheck
Typeboolean
Defaultfalse

value

Description

The value of the textarea.

Attributevalue
Typenull | string | undefined
Default''

wrap

Description

Indicates how the control wraps text.

Attributewrap
Type"hard" | "off" | "soft" | undefined

ion-textarea 事件(Events)

NameDescription
ionBlurEmitted when the input loses focus.
ionChangeEmitted when the input value has changed.
ionFocusEmitted when the input has focus.
ionInputEmitted when a keyboard input ocurred.

ion-textarea 内置方法(Methods)

getInputElement

Description

Returns the native <textarea> element used under the hood.

SignaturegetInputElement() => Promise<HTMLTextAreaElement>

setFocus

Description

Sets focus on the specified ion-textarea. Use this method instead of the global input.focus().

SignaturesetFocus() => void

ion-textarea中的CSS 自定义属性

NameDescription
--backgroundBackground of the textarea
--border-radiusBorder radius of the textarea
--colorColor of the text
--padding-bottomBottom padding of the textarea
--padding-endEnd padding of the textarea
--padding-startStart padding of the textarea
--padding-topTop padding of the textarea
--placeholder-colorColor of the placeholder text
--placeholder-font-styleStyle of the placeholder text
--placeholder-font-weightWeight of the placeholder text
--placeholder-opacityOpacity of the placeholder text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文