mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-09-13 00:50:40 +08:00
refactor: 架构升级
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
# text
|
||||
|
||||
## Instructions
|
||||
|
||||
文本组件。用于包裹文本内容。
|
||||
|
||||
在app-uvue和app-nvue中,文本只能写在text中,而不能写在view的text区域。
|
||||
|
||||
虽然app-uvue中写在view的text区域的文字,也会被编译器自动包裹一层text组件,看起来也可以使用。但这样会造成无法修改该text文字的样式,详见uvue的 样式不继承 章节
|
||||
|
||||
### Syntax
|
||||
|
||||
- 使用 `<text />`(或 `<text></text>`,当需要包裹子节点时)。
|
||||
- 遇到平台差异时,建议使用条件编译(`#ifdef / #endif`)显式处理。
|
||||
|
||||
#### Properties
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 平台差异说明 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| selectable | Boolean | false | 文本是否可选 | 小红书小程序不支持 |
|
||||
| user-select | Boolean | false | 文本是否可选 | 微信小程序 |
|
||||
| space | String | | 显示连续空格 | 钉钉小程序不支持 |
|
||||
| decode | Boolean | false | 是否解码 | 百度、钉钉小程序不支持 |
|
||||
|
||||
#### Events
|
||||
|
||||
See official docs for full events list: `https://uniapp.dcloud.net.cn/component/text.html`
|
||||
|
||||
#### Platform Compatibility
|
||||
|
||||
See official docs for platform support table: `https://uniapp.dcloud.net.cn/component/text.html`
|
||||
|
||||
### Examples
|
||||
|
||||
### Example (Example 1)
|
||||
|
||||
```vue
|
||||
<!-- 本示例未包含完整css,获取外链css请参考上文,在hello uni-app项目中查看 -->
|
||||
<template>
|
||||
<view>
|
||||
<view class="uni-padding-wrap uni-common-mt">
|
||||
<view class="text-box" scroll-y="true">
|
||||
<text>{{text}}</text>
|
||||
</view>
|
||||
<view class="uni-btn-v">
|
||||
<button type="primary" :disabled="!canAdd" @click="add">add line</button>
|
||||
<button type="warn" :disabled="!canRemove" @click="remove">remove line</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
```
|
||||
|
||||
### Example (Example 2)
|
||||
|
||||
```vue
|
||||
<!-- 本示例未包含完整css,获取外链css请参考上文,在hello uni-app项目中查看 -->
|
||||
<template>
|
||||
<view>
|
||||
<view class="uni-padding-wrap uni-common-mt">
|
||||
<view class="text-box" scroll-y="true">
|
||||
<text>{{text}}</text>
|
||||
</view>
|
||||
<view class="uni-btn-v">
|
||||
<button type="primary" :disabled="!canAdd" @click="add">add line</button>
|
||||
<button type="warn" :disabled="!canRemove" @click="remove">remove line</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
```
|
||||
|
||||
### Example (Example 3)
|
||||
|
||||
```vue
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
texts: [
|
||||
'HBuilder,900万开发者选择的IDE',
|
||||
'MUI,轻巧、漂亮的前端开源框架',
|
||||
'wap2app,M站快速转换原生体验的App',
|
||||
'5+Runtime,为HTML5插上原生的翅膀',
|
||||
'HBuilderX,轻巧、极速,极客编辑器',
|
||||
'uni-app,终极跨平台方案',
|
||||
'HBuilder,900万开发者选择的IDE',
|
||||
'MUI,轻巧、漂亮的前端开源框架',
|
||||
'wap2app,M站快速转换原生体验的App',
|
||||
'5+Runtime,为HTML5插上原生的翅膀',
|
||||
'HBuilderX,轻巧、极速,极客编辑器',
|
||||
'uni-app,终极跨平台方案',
|
||||
'......'
|
||||
],
|
||||
text: '',
|
||||
canAdd: true,
|
||||
canRemove: false,
|
||||
extraLine: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add: function(e) {
|
||||
this.extraLine.push(this.texts[this.extraLine.length % 12]);
|
||||
this.text = this.extraLine.join('\n');
|
||||
this.canAdd = this.extraLine.length < 12;
|
||||
this.canRemove = this.extraLine.length > 0;
|
||||
},
|
||||
remove: function(e) {
|
||||
if (this.extraLine.length > 0) {
|
||||
this.extraLine.pop();
|
||||
this.text = this.extraLine.join('\n');
|
||||
this.canAdd = this.extraLine.length < 12;
|
||||
this.canRemove = this.extraLine.length > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
Reference: [Official Documentation](https://uniapp.dcloud.net.cn/component/text.html)
|
||||
Reference in New Issue
Block a user