Home  >  Article  >  WeChat Applet  >  WeChat applet wxapp content component text detailed introduction

WeChat applet wxapp content component text detailed introduction

高洛峰
高洛峰Original
2017-02-14 14:19:291870browse

WeChat applet content component: text

Text node, supports the escape character "\".

Nodes other than text nodes cannot be selected by long pressing

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 = &#39;this is first line\nthis is second line&#39;
Page({
 data: {
 text: initData
 },
 extraLine: [],
 add: function(e) {
 this.extraLine.push(&#39;other line&#39;)
 this.setData({
  text: initData + &#39;\n&#39; + this.extraLine.join(&#39;\n&#39;)
 })
 },
 remove: function(e) {
 if (this.extraLine.length > 0) {
  this.extraLine.pop()
  this.setData({
  text: initData + &#39;\n&#39; + this.extraLine.join(&#39;\n&#39;)
  })
 }
 }
})

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

More WeChat mini programs wxapp content components text For detailed introduction and related articles, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn