简体中文
组件类型:UniTextElement
文本
Android | iOS | web |
---|---|---|
3.9 | 4.11 | 4.0 |
在app-uvue和app-nvue中,文本只能写在text中,而不能写在view的text区域。文本样式的控制也应该在text组件上写style,而不是在view的样式里写。
虽然app-uvue中写在view的text区域的文字,也会被编译器自动包裹一层text组件,看起来也可以使用。但这样会造成无法修改该text文字的样式,详见uvue的样式不继承章节。
名称 | 类型 | 默认值 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selectable | boolean | false | 文本是否可选 | ||||||||
space | string | - | 显示连续空格 | ||||||||
| |||||||||||
decode | boolean | false | 是否解码 (Android 端如需解析字符实体,需要配置为 true) |
Android | iOS | web | |
---|---|---|---|
ensp | 3.9 | 4.11 | 4.0 |
emsp | 3.9 | 4.11 | 4.0 |
nbsp | 3.9 | 4.11 | 4.0 |
Android | iOS | web | |
---|---|---|---|
selectable | 3.9 | 4.11 | 4.0 |
space | 3.9 | 4.11 | 4.0 |
decode | 3.9 | 4.11 | 4.0 |
text组件在web浏览器渲染(含浏览器、小程序webview渲染模式、app-vue)和uvue中,可以并只能嵌套text组件。
app-uvue中的 text 组件虽然支持嵌套,但子组件不继承父组件样式。这样使用会在编译到各平台时可能产生差异,所以尽量避免使用text嵌套。
app 平台子组件设置的排版相关样式(如position、display、width、height、margin、padding等)以及部分text独有样式(如text-align、lines、white-space、text-overflow)不生效,
Template
Script
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text class="text">{{ text }}</text>
</view>
<view class="uni-btn-v">
<button class="uni-btn" type="primary" :disabled="!canAdd" @click="add">
add line
</button>
<button class="uni-btn" type="warn" :disabled="!canRemove" @click="remove">
remove line
</button>
<button class="uni-btn" type="primary" @click="textProps">
更多属性示例
</button>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<style>
.text-box {
margin-bottom: 20px;
padding: 20px 0;
display: flex;
min-height: 150px;
background-color: #ffffff;
justify-content: center;
align-items: center;
}
.text {
font-size: 15px;
color: #353535;
line-height: 27px;
text-align: center;
}
</style>