English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Detailed Introduction of WeChat Mini Program wxapp Content Component text

WeChat Mini Program content components

Related Articles:

WeChat Mini Program wxapp content component icon

WeChat Mini Program wxapp content component text

WeChat Mini Program wxapp content component progress

WeChat Mini Program content component: text

Text nodes support escape characters "\".

Other nodes except text nodes cannot be long-pressed and selected.

Example:

<view class="section section_gap">
 <text>{{text}}</text>
 <view class="btn-area>
  <button bindtap="add">add line</button>
  <button bindtap="remove">remove line</button>
 </view>
</view>
var initData = 'this is first line\nthis is second line'
Page({
 data: {
 text: initData
 ,
 extraLine: [],
 add: function(e) {
 this.extraLine.push('other line')
 this.setData({
  text: initData + '\n' + this.extraLine.join('\n')
 }
 ,
 remove: function(e) {
 if (this.extraLine.length > 0) {
  this.extraLine.pop()
  this.setData({
  text: initData + '\n' + this.extraLine.join('\n')
  }
 }
 }
}

Thank you for reading, I hope it can help everyone, thank you for your support to this site!

You May Also Like