<template>
	<view>
		<!-- 顶部 -->
		<view class="uni-head">
			<view class="uni-head-title">
				text 文本
			</view>			
		</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>

<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:'',
					arr:[],
					canAdd: true,
					canRemove: false,
					
			}
		},
		methods: {
			add(){
				// var i;
				// for(i=0;i<this.texts.length;i++){
				// 	this.arr.push(this.texts[i]);					
				// }
				this.arr.push(this.texts[this.arr.length % 12]);
				this.text =this.arr.join('\n')
				this.canAdd = this.arr.length < 12;
				this.canRemove = this.arr.length > 0;
			},
			remove(){
				if (this.arr.length > 0) {
				        this.arr.pop();
						this.text = this.arr.join('\n');
				        this.canAdd = this.arr.length < 12;
				        this.canRemove = this.arr.length > 0;
				    }
			}
		}
	}
</script>

<style>
@import url('../../lib/smart.css');
.text-box{
	min-height: 300rpx;
	max-height: 900rpx;
	padding: 25rpx 0;
	margin: 20rpx;
	text-align: center;
	background-color:#eee;
	color: #55007f;
	line-height: 1.8;
	
}
</style>
