小程序对wxParse 使用
生活随笔
收集整理的這篇文章主要介紹了
小程序对wxParse 使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我的后臺是使用ck編輯器進行編輯的數據。前臺需要現實,并且是列表現實,主要面對的問題是一個項里有兩個字段是多行文本的,并且是一個列表。所以和網上的還是不一樣
var WxParse = require('../../../wxParse/wxParse'); const app = getApp(); Page({/*** 頁面的初始數據*/data: {jgpgList:[],//機構評估項jgpgCount:0},/*** 生命周期函數--監聽頁面加載*/onLoad: function (options) {var that=this;var cateid=options.cateId;var jgid=options.JgId;that.getpgitems(cateid,jgid);},/*** 生命周期函數--監聽頁面初次渲染完成*/onReady: function () {},/*** 生命周期函數--監聽頁面顯示*/onShow: function () {},/*** 生命周期函數--監聽頁面隱藏*/onHide: function () {},/*** 生命周期函數--監聽頁面卸載*/onUnload: function () {},/*** 頁面相關事件處理函數--監聽用戶下拉動作*/onPullDownRefresh: function () {},/*** 頁面上拉觸底事件的處理函數*/onReachBottom: function () {},/*** 用戶點擊右上角分享*/onShareAppMessage: function () {},getpgitems:function(cateId,jgId){//查詢機構類別var that = this;wx.showLoading({title: '加載中......',mask: true})//進入大列表頁查詢信息wx.request({url: app.globalData.apiUrl+'WxXcx/YangLaoYan/GetJgPgItems',data:{JgId:jgId,cateId:cateId,LoginKey: wx.getStorageSync('loginKey')},method: 'GET',header: {'content-type': 'application/json'},success: function (res) {that.setData({jgpgList: res.data.data.data,jgpgCount:res.data.data.count})var listRes=res.data.data.data; //要解析的數據for (let i = 0; i < listRes.length; i++) {WxParse.wxParse('option' + i, 'html', listRes[i].Option, that);WxParse.wxParse('optionsm' + i, 'html', listRes[i].OptionSm, that);if (i === listRes.length - 1) {WxParse.wxParseTemArray("listoption", 'option', listRes.length, that)WxParse.wxParseTemArray("listoptionsm", 'optionsm', listRes.length, that)}}let list = that.data.listoption;list.map((item, index, arr) => { listRes[index].option=item;});let listsm = that.data.listoptionsm;listsm.map((item, index, arr) => { listRes[index].optionsm=item;});that.setData({jgpgList: listRes,})wx.hideLoading();}})},pinggu:function(e){//評估} })wxml:
<!--養老院機構評估項信息查看頁--> <import src="/wxParse/wxParse.wxml"/> <cu-custom bgColor="bg-gradual-blue" isBack="{{true}}" ><view slot="backText">返回</view><view slot="content">評估項</view> </cu-custom> <view class="content" wx:if="{{jgpgCount>0}}"> <view class="row margin-top" wx:for="{{jgpgList}}"> <view class="pinggu-title">{{item.Bcode}}</view> <view class="pinggu-title">評定項:</view> <view class="pdx-content"><template is="wxParse" data="{{wxParseData:item.option}}"/> </view> <view class="pinggu-title">操作說明:</view> <view class="czsm-content"><template is="wxParse" data="{{wxParseData:item.optionsm}}"/> </view> <view class="pinggu-title">分值:</view> <view class="czsm-content">{{item.Bscore}} 分</view> <view ><text class="pinggu-title">狀態:</text><text>{{item.ScoreStateDic}}</text></view> <view class="pinggaction"> <view catchtap="pinggu" class="cu-capsule radius " ><text class="cuIcon-edit text-orange scopbtn"> </text><text class="text-orange pgtitle">評估</text> </view></view> </view></view> <view class="{{jgpgCount>0?'hidenodata':'nodata'}}" wx:else>沒有數據........... </view>總結
以上是生活随笔為你收集整理的小程序对wxParse 使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何使用组策略映射网络驱动器
- 下一篇: 单词的理解 —— 词义的变化(翻译)