miniprogram-demo/pages/component/text/text.js

61 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const texts = [
'2011年1月微信1.0发布',
'同年5月微信2.0语音对讲发布',
'10月微信3.0新增摇一摇功能',
'2012年3月微信用户突破1亿',
'4月份微信4.0朋友圈发布',
'同年7月微信4.2发布公众平台',
'2013年8月微信5.0发布微信支付',
'2014年9月企业号发布',
'同月,发布微信卡包',
'2015年1月微信第一条朋友圈广告',
'2016年1月企业微信发布',
'2017年1月小程序发布',
'......'
]
Page({
onShareAppMessage() {
return {
title: 'text',
path: 'pages/component/text/text'
}
},
data: {
text: '',
canAdd: true,
canRemove: false
},
extraLine: [],
add() {
this.extraLine.push(texts[this.extraLine.length % 12])
this.setData({
text: this.extraLine.join('\n'),
canAdd: this.extraLine.length < 12,
canRemove: this.extraLine.length > 0
})
setTimeout(() => {
this.setData({
scrollTop: 99999
})
}, 0)
},
remove() {
if (this.extraLine.length > 0) {
this.extraLine.pop()
this.setData({
text: this.extraLine.join('\n'),
canAdd: this.extraLine.length < 12,
canRemove: this.extraLine.length > 0,
})
}
setTimeout(() => {
this.setData({
scrollTop: 99999
})
}, 0)
}
})