text-props.uvue 5.6 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
<template>
  <scroll-view class="page-scroll-view">
    <page-head :title="title"></page-head>
    <view class="uni-padding-wrap uni-common-mt">
      <view class="uni-title">
        <text class="uni-title-text">text相关属性示例</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">根据宽度自动折行</text>
      </view>
      <view class="text-box">
        <text>{{ multiLineText }}</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">\\n换行</text>
      </view>
      <view class="text-box">
        <text>\n 换行</text>
        <text>\\n 换行</text>
        <text>\\\n 换行</text>
        <text>\n 换行 \\n 换行 \\\n 换行 \\\\n 换行 \\\\\n 换行</text>
        <text space="nbsp">HBuilderX,轻巧、极速,极客编辑器;\nuni-app x,终极跨平台方案;</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">截断(clip)</text>
      </view>
      <view class="text-box">
        <text class="uni-flex-item" style="width: 100%;text-overflow: clip;white-space: nowrap;">{{
          multiLineText
        }}</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">截断(ellipsis)</text>
      </view>
      <view class="text-box">
        <text class="uni-flex-item" style="width: 100%;text-overflow: ellipsis;white-space: nowrap;">{{
          multiLineText
        }}</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">selectable</text>
      </view>
      <view class="text-box">
        <text :selectable="true">{{ singleLineText }}</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">space</text>
        <text class="uni-subtitle-text">依次为nbsp ensp emsp效果</text>
      </view>
      <view class="text-box">
        <text space="nbsp">{{ singleLineText }}</text>
        <text space="ensp">{{ singleLineText }}</text>
        <text space="emsp">{{ singleLineText }}</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">decode</text>
        <text class="uni-subtitle-text">依次为lt gt amp apos nbsp ensp emsp效果</text>
      </view>
      <view class="text-box">
        <text :decode="true">&lt; &gt; &amp; &apos;</text>
        <text :decode="true">uni-app&nbsp;x,终极跨平台方案</text>
        <text :decode="true">uni-app&ensp;x,终极跨平台方案</text>
        <text :decode="true">uni-app&emsp;x,终极跨平台方案</text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">嵌套1</text>
      </view>
      <view class="text-box">
        <text>一级节点黑色
          <text style="color: red;background-color: yellow;">二级节点红色且背景色黄色
            <text>App三级节点不继承二级的颜色</text>
          </text>
          <text style="font-size: 50px">二级节点大字体</text>
        </text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">嵌套2</text>
      </view>
      <view class="text-box">
        <text>
          <text>文字应居中显示</text>
        </text>
      </view>

      <view class="uni-title">
        <text class="uni-subtitle-text">padding和border</text>
      </view>
      <view class="text-box">
        <text class="text-padding-border">hello uni-app x</text>
        <text class="text-padding-border" style="width: 200px;">hello uni-app x</text>
        <text class="text-padding-border" style="height: 100px;">hello uni-app x</text>
        <text class="text-padding-border" style="width: 200px;height: 100px;">hello uni-app x</text>
      </view>

      <view v-if="autoTest">
        <view class="uni-row">
          <text id="empty-text"></text>
        </view>
        <view class="uni-row">
          <text id="empty-text2">{{emptyText}}</text>
        </view>
        <text>一级节点文本
          <text>二级节点文本
            <text id="nested-text">{{nestedText}}</text>
          </text>
        </text>
        <text id="height-text" style="height: 50px;">{{heightText}}</text>
      </view>
    </view>
  </scroll-view>
</template>

<script>
  export default {
    data() {
      return {
        title: 'text-props',
        multiLineText:
          'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言;HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言',
        singleLineText: 'uni-app x,终极跨平台方案',
        // 自动化测试
        autoTest: false,
        nestedText: '三级节点文本',
        emptyText: '空文本',
        heightText: '设置高度文本'
      }
    },
    methods: {
      // 自动化测试
      setNestedText() {
        this.nestedText = "修改三级节点文本";
      },
      setEmptyText() {
        this.emptyText = "";
      },
      setHeightText() {
        this.heightText = "修改设置高度文本";
      }
    }
  }
</script>

<style>
  .text-box {
    margin-bottom: 20px;
    padding: 20px 0;
    background-color: #ffffff;
    justify-content: center;
    align-items: center;
  }

  .text {
    font-size: 15px;
    color: #353535;
    line-height: 27px;
    text-align: center;
  }

  .text-padding-border {
    margin-top: 5px;
    padding: 20px;
    border: 5px solid red;
    text-align: center;
  }
DCloud-WZF's avatar
DCloud-WZF 已提交
174
</style>