首页 > 代码库 > 微信小程序组件text

微信小程序组件text

基础内容text:官方文档

Demo Code

技术分享
var initData = http://www.mamicode.com/‘this is first line/nthis is second line‘"color: #0000ff;">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‘)      })    }  }})
JS
技术分享
<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>
WXML
技术分享
.btn-area{    font-family:Verdana, Geneva, Tahoma, sans-serif;    padding: 0 10px 0 10px;}.body-view button{    margin-top :10px;}
WXSS

 

微信小程序组件text