小程序换行符检测换行

先将换行符替换成自定义连接字符

var goods_detail = ""
if(res.data.info.goods_info.goods_detail){
goods_detail = res.data.info.goods_info.goods_detail;
var str=goods_detail.replace(/\n/g,"|-&");
var goods_detail1 = str.split("|-&");
if(goods_detail1[0]){
goods_detail1 = goods_detail1;
}else{
goods_detail1[0] = goods_detail
}
}

 

然后循环输出数组

<view class="productIntro_text">
<view wx:for="{{goods_detail1}}">{{item}}</view>
</view>

 

posted @ 2017-10-26 21:13  好想再胖十斤  阅读(4955)  评论(0编辑  收藏  举报