// pages/agreements/index.js import towxml from "towxml" import { alertInfo } from "../../../utils/index"; Page({ /** * 页面的初始数据 */ data: { url: "" }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { const { url } = options; this.getText(url, this.setText) }, getText: (url, callback) => { wx.request({ url: url, header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { if (typeof callback === 'function') { callback(res); }; }, fail: (err) => { alertInfo(err) } }); }, async setText(res) { let obj = towxml(res.data,'markdown',{        theme:'light', //主题 dark 黑色,light白色,不填默认是light //        base:"www.xxx.com", events:{      //为元素绑定的事件方法 tap:e => { console.log('tap',e); }, change:e => { console.log('todo',e); } } });      //更新解析数据 this.setData({ text:obj, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })