text.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view>
  3. <page-head :title="title"></page-head>
  4. <view class="uni-padding-wrap uni-common-mt">
  5. <view class="text-box" scroll-y="true">
  6. <text>{{text}}</text>
  7. </view>
  8. <view class="uni-btn-v">
  9. <button type="primary" :disabled="!canAdd" @click="add">add line</button>
  10. <button type="warn" :disabled="!canRemove" @click="remove">remove line</button>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. title: 'text',
  20. texts: [
  21. 'HBuilder,400万开发者选择的IDE',
  22. 'MUI,轻巧、漂亮的前端开源框架',
  23. 'wap2app,M站快速转换原生体验的App',
  24. '5+Runtime,为HTML5插上原生的翅膀',
  25. 'HBuilderX,轻巧、极速,极客编辑器',
  26. 'uni-app,终极跨平台方案',
  27. 'HBuilder,400万开发者选择的IDE',
  28. 'MUI,轻巧、漂亮的前端开源框架',
  29. 'wap2app,M站快速转换原生体验的App',
  30. '5+Runtime,为HTML5插上原生的翅膀',
  31. 'HBuilderX,轻巧、极速,极客编辑器',
  32. 'uni-app,终极跨平台方案',
  33. '......'
  34. ],
  35. text: '',
  36. canAdd: true,
  37. canRemove: false,
  38. extraLine: []
  39. }
  40. },
  41. methods: {
  42. add: function(e) {
  43. this.extraLine.push(this.texts[this.extraLine.length % 12]);
  44. this.text = this.extraLine.join('\n');
  45. this.canAdd = this.extraLine.length < 12;
  46. this.canRemove = this.extraLine.length > 0;
  47. },
  48. remove: function(e) {
  49. if (this.extraLine.length > 0) {
  50. this.extraLine.pop();
  51. this.text = this.extraLine.join('\n');
  52. this.canAdd = this.extraLine.length < 12;
  53. this.canRemove = this.extraLine.length > 0;
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style>
  60. .text-box {
  61. margin-bottom: 40rpx;
  62. padding: 40rpx 0;
  63. display: flex;
  64. min-height: 300rpx;
  65. background-color: #FFFFFF;
  66. justify-content: center;
  67. align-items: center;
  68. text-align: center;
  69. font-size: 30rpx;
  70. color: #353535;
  71. line-height: 1.8;
  72. }
  73. </style>