text.uvue 2.7 KB
Newer Older
Y
init  
yurj26 已提交
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
<template>
    <view>
        <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>
            </view>
        </view>
    </view>
</template>
<script lang="ts">
    export default {
        data() {
            return {
                title: 'text',
                texts: [
                    'HBuilder,400万开发者选择的IDE',
                    'MUI,轻巧、漂亮的前端开源框架',
                    'wap2app,M站快速转换原生体验的App',
                    '5+Runtime,为HTML5插上原生的翅膀',
                    'HBuilderX,轻巧、极速,极客编辑器',
                    'uni-app,终极跨平台方案',
                    'HBuilder,400万开发者选择的IDE',
                    'MUI,轻巧、漂亮的前端开源框架',
                    'wap2app,M站快速转换原生体验的App',
                    '5+Runtime,为HTML5插上原生的翅膀',
                    'HBuilderX,轻巧、极速,极客编辑器',
                    'uni-app,终极跨平台方案',
                    '......'
                ] as string[],
                text: '',
                canAdd: true,
                canRemove: false,
                extraLine: [] as string[]
            }
        },
        methods: {
            add: function () {
                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 () {
                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>

<style>
    .text-box {
        margin-bottom: 40rpx;
        padding: 40rpx 0;
        display: flex;
Y
yurj26 已提交
65
        min-height: 300rpx;
Y
init  
yurj26 已提交
66 67 68 69 70 71 72 73
        background-color: #FFFFFF;
        justify-content: center;
        align-items: center;
    }

    .text {
        font-size: 30rpx;
        color: #353535;
Y
yurj26 已提交
74 75
        line-height: 54rpx;
        text-align: center;
Y
init  
yurj26 已提交
76 77
    }
</style>