text.uvue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex: 1">
  4. <!-- #endif -->
  5. <page-head :title="title"></page-head>
  6. <view class="uni-padding-wrap uni-common-mt">
  7. <view class="text-box">
  8. <text class="text">{{ text }}</text>
  9. </view>
  10. <view class="uni-btn-v">
  11. <button class="uni-btn" type="primary" :disabled="!canAdd" @click="add">
  12. add line
  13. </button>
  14. <button class="uni-btn" type="warn" :disabled="!canRemove" @click="remove">
  15. remove line
  16. </button>
  17. <button class="uni-btn" type="primary" @click="textProps">
  18. 更多属性示例
  19. </button>
  20. </view>
  21. </view>
  22. <!-- #ifdef APP -->
  23. </scroll-view>
  24. <!-- #endif -->
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. title: 'text',
  31. texts: [
  32. 'HBuilderX,轻巧、极速,极客编辑器',
  33. 'uni-app x,终极跨平台方案',
  34. 'uniCloud,js serverless云服务',
  35. 'uts,大一统语言',
  36. 'uniMPSdk,让你的App具备小程序能力',
  37. 'uni-admin,开源、现成的全端管理后台',
  38. 'uni-id,开源、全端的账户中心',
  39. 'uni-pay,开源、云端一体、全平台的支付',
  40. 'uni-ai,聚合ai能力',
  41. 'uni-cms,开源、云端一体、全平台的内容管理平台',
  42. 'uni-im,开源、云端一体、全平台的im即时消息',
  43. 'uni统计,开源、完善、全平台的统计报表',
  44. '......'
  45. ] as string[],
  46. text: '',
  47. canAdd: true,
  48. canRemove: false,
  49. extraLine: [] as string[]
  50. }
  51. },
  52. methods: {
  53. add: function () {
  54. this.extraLine.push(this.texts[this.extraLine.length % 12]);
  55. this.text = this.extraLine.join('\n');
  56. this.canAdd = this.extraLine.length < 12;
  57. this.canRemove = this.extraLine.length > 0;
  58. },
  59. remove: function () {
  60. if (this.extraLine.length > 0) {
  61. this.extraLine.pop();
  62. this.text = this.extraLine.join('\n');
  63. this.canAdd = this.extraLine.length < 12;
  64. this.canRemove = this.extraLine.length > 0;
  65. }
  66. },
  67. textProps: function () {
  68. uni.navigateTo({
  69. url: '/pages/component/text/text-props'
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .text-box {
  77. margin-bottom: 20px;
  78. padding: 20px 0;
  79. display: flex;
  80. min-height: 150px;
  81. background-color: #ffffff;
  82. justify-content: center;
  83. align-items: center;
  84. }
  85. .text {
  86. font-size: 15px;
  87. color: #353535;
  88. line-height: 27px;
  89. text-align: center;
  90. }
  91. </style>