// index.js let myPro = require("../../utils/wxRequest.js"); let util = require("../../utils/util.js"); Page({ data: { id: '', htmlSnip: '' }, onLoad: function (options) { // Do some initialize when page load. let that = this; that.setData({ id: options.id }); }, onShow: function () { // Do something when page show. let that = this; that.getContent(); }, onReady: function () { // Do something when page ready. }, onHide: function () { // Do something when page hide. }, onUnload: function () { // Do something when page close. }, onPullDownRefresh: function () { // Do something when pull down. }, onReachBottom: function () { // Do something when page reach bottom. }, onPageScroll: function () { // Do something when page scroll }, onResize: function () { // Do something when page resize }, // 获取单页内容 getContent(){ let that = this; let params = { id: that.data.id }; myPro.wxRequest("user/v3/article/detail","GET",params).then(res=>{ let contents = res.result.content; // 小程序内置,转富文本标签,仅对rich-text 中的 class 生效 contents = contents.replace(/\/g, '') that.setData({ htmlSnip: contents }); }).catch(err=>{ console.log('报错信息',err); wx.showToast({ title: err, icon: "none" }) }) } });