提交 38d0fe3e 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

style: 修复 data 中 texts 换行错乱问题

上级 d23c8e45
<template> <template>
<view> <view>
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true"> <view class="text-box" scroll-y="true">
<text class="text">{{text}}</text> <text class="text">{{ text }}</text>
</view> </view>
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn" type="primary" :disabled="!canAdd" @click="add">add line</button> <button class="uni-btn" type="primary" :disabled="!canAdd" @click="add">
<button class="uni-btn" type="warn" :disabled="!canRemove" @click="remove">remove line</button> add line
<button class="uni-btn" type="primary" @click="textProps">更多属性示例</button> </button>
</view> <button
</view> class="uni-btn"
type="warn"
:disabled="!canRemove"
@click="remove"
>
remove line
</button>
<button class="uni-btn" type="primary" @click="textProps">
更多属性示例
</button>
</view>
</view> </view>
</view>
</template> </template>
<script lang="uts"> <script lang="uts">
export default { export default {
data() { data() {
return { return {
title: 'text', title: 'text',
texts: [ texts: [
'HBuilderX,轻巧、极速,极客编辑器', 'HBuilderX,轻巧、极速,极客编辑器',
'uni-app x,终极跨平台方案', 'uni-app x,终极跨平台方案',
'uniCloud,js serverless云服务', 'uniCloud,js serverless云服务',
'uts,大一统语言', 'uts,大一统语言',
'uniMPSdk,让你的App具备小程序能力', 'uniMPSdk,让你的App具备小程序能力',
'uni-admin,开源、现成的全端管理后台', 'uni-admin,开源、现成的全端管理后台',
'uni-id,开源、全端的账户中心', 'uni-id,开源、全端的账户中心',
'uni-pay,开源、云端一体、全平台的支付', 'uni-pay,开源、云端一体、全平台的支付',
'uni-ai,聚合ai能力', 'uni-ai,聚合ai能力',
'uni-cms,开源、云端一体、全平台的内容管理平台', 'uni-cms,开源、云端一体、全平台的内容管理平台',
'uni-im,开源、云端一体、全平台的im即时消息', 'uni-im,开源、云端一体、全平台的im即时消息',
'uni统计,开源、完善、全平台的统计报表', 'uni统计,开源、完善、全平台的统计报表',
'......' '......'
] as string[], ] as string[],
text: '', text: '',
canAdd: true, canAdd: true,
canRemove: false, canRemove: false,
extraLine: [] as string[] 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;
}, },
methods: { remove: function () {
add: function () { if (this.extraLine.length > 0) {
this.extraLine.push(this.texts[this.extraLine.length % 12]); this.extraLine.pop();
this.text = this.extraLine.join('\n'); this.text = this.extraLine.join('\n');
this.canAdd = this.extraLine.length < 12; this.canAdd = this.extraLine.length < 12;
this.canRemove = this.extraLine.length > 0; this.canRemove = this.extraLine.length > 0;
}, }
remove: function () { },
if (this.extraLine.length > 0) { textProps: function () {
this.extraLine.pop(); uni.navigateTo({
this.text = this.extraLine.join('\n'); url: '/pages/component/text/text-props'
this.canAdd = this.extraLine.length < 12; })
this.canRemove = this.extraLine.length > 0; }
}
},
textProps: function () {
uni.navigateTo({
url: '/pages/component/text/text-props'
})
}
}
} }
}
</script> </script>
<style> <style>
.text-box { .text-box {
margin-bottom: 40rpx; margin-bottom: 40rpx;
padding: 40rpx 0; padding: 40rpx 0;
display: flex; display: flex;
min-height: 300rpx; min-height: 300rpx;
background-color: #FFFFFF; background-color: #ffffff;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.text { .text {
font-size: 30rpx; font-size: 30rpx;
color: #353535; color: #353535;
line-height: 54rpx; line-height: 54rpx;
text-align: center; text-align: center;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册