基础内容text:官方文档
Demo Code
var initData = ‘this is first line\nthis is second line‘ var extraLine = []; Page({ data: { text: initData }, add: function(e) { extraLine.push(‘other line‘) this.setData({ text: initData + ‘\n‘ + extraLine.join(‘\n‘) }) }, remove: function(e) { if (extraLine.length > 0) { extraLine.pop() this.setData({ text: initData + ‘\n‘ + extraLine.join(‘\n‘) }) } } })
<view class="btn-area"> <view class="body-view"> <text>{{text}}</text> <button bindtap="add">add line</button> <button bindtap="remove">remove line</button> </view> </view>
.btn-area{ font-family:Verdana, Geneva, Tahoma, sans-serif; padding: 0 10px 0 10px; } .body-view button{ margin-top :10px; }