title: Text

sidebar_label: Text

Text.

Reference

Type

  1. ComponentType<TextProps>

Examples

import Tabs from ‘@theme/Tabs’; import TabItem from ‘@theme/TabItem’;

tsx export default class PageView extends Component { state = { contents: [], contentsLen: 0 } add = () => { this.setState(prev => { const cot = prev.contents.slice() cot.push({ text: 'hello world' }) return { contents: cot, contentsLen: cot.length } }) } remove = () => { this.setState(prev => { const cot = prev.contents.slice() cot.pop() return { contents: cot, contentsLen: cot.length } }) } render () { return ( <View className='container'> {this.state.contents.map((item, index) => ( <Text key={index}>{item.text}</Text> ))} <Button className='btn-max-w button_style' plain type='default' onClick={this.add}>add line</Button> <Button className='btn-max-w button_style' plain type='default' disabled={this.state.contentsLen ? false : true} onClick={this.remove}>remove line</Button> </View> ) } } html <template> <view class="container"> <view v-for="(item, index) in contents"> <text>{{item.text}} line {{index + 1}}</text> </view> <button class="btn-max-w button_style" :plain="true" type="default" @tap="add">add line</button> <button class="btn-max-w button_style" :plain="true" type="default" :disabled="contentsLen ? false : true" @tap="remove">remove line</button> </template> <script> export default { data() { return { contents: [], contentsLen: 0 } }, methods: { add () { const cot = this.contents.slice() cot.push({ text: 'hello world' }) this.contents = cot this.contentsLen = cot.length }, remove () { const cot = this.contents.slice() cot.pop() this.contents = cot this.contentsLen = cot.length } } } </script>

TextProps

Property Type Default Required Description
selectable boolean false No Specifies whether the text is selectable
space "ensp" | "emsp" | "nbsp" No Displays consecutive spaces
decode boolean false No Specifies whether to decode component

Property Support

Property WeChat Mini-Program Baidu Smart-Program Alipay Mini-Program ByteDance Micro-App H5 React Native
TextProps.selectable ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
TextProps.space ✔️ ✔️ ✔️
TextProps.decode ✔️ ✔️

TSpace

Valid values of space

Value Description
ensp En space
emsp Em space
nbsp The size of the space is set according to the font setting

API Support

API WeChat Mini-Program Baidu Smart-Program Alipay Mini-Program ByteDance Micro-App H5 React Native
Text ✔️ ✔️ ✔️ ✔️ ✔️ ✔️