欢迎来到258分享网,纯净的网络源码分享基地!

258资源分享网

全部作品
全部作品
网站源码
微信源码
素材特效
源码插件
视频教程
建站学院
热门搜索: 织梦  农业种植  农业  安全设置  官方
258资源分享 > 建站学院 > 微信开发 > 微信小程序调用PHP后台接口,解析纯html文本

推荐下载

HTML5响应式自适应网咯设计

2020-05-12   浏览:740

高端HTML5响应式企业通用网

2020-05-06   浏览:521

html5响应式外贸网站英文版

2020-05-08   浏览:510

HTML5自适应律师工作室类网

2020-04-04   浏览:504

HTML5影视传媒文化公司类网

2020-05-12   浏览:501

微信小程序调用PHP后台接口,解析纯html文本

发布时间:2020-12-31  

1、微信js动态传参:wx.request({ url: 'https://m.****.com/index.php/Home/Xiaoxxf/activity_detail?a_id='+options.id,//含富文本html data: { is_detail:1 }, method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, ...

 

 

 

微信小程序调用PHP后台接口,解析纯html文本

微信小程序调用PHP后台接口,解析纯html文本

1、微信js动态传参:

 

wx.request({

url:'https://m.****.com/index.php/Home/Xiaoxxf/activity_detail?a_id='+options.id,//含富文本html

data:{

is_detail:1

},

method:'GET',// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT

header:{

'Content-Type':'application/json'

},

success:function(res){

that.setData({

Article: res.data //一维数组json编码后对象

})

 

/**

* html解析

*/

var article = that.data.Article;

console.log("article = "+ article);

WxParse.wxParse('article','html', article, that,5);

console.log(res.data);

},

fail:function(res){},

complete:function(res){},

}),

其中,options.id是由前一个wxml页面动态传过来的参数。

2、wxParse插件使用:  github地址: https://github.com/icindy/wxParse,版本0.2  解决问题:微信小程序富文本html、md解析组件

1)复制wxParse文件夹到pages同目录  2)在wxml页面引入模板代码:  富文本html框内容:

3)在js的page({})里面引入执行文件  // 引入wxParse.js解析文件  var WxParse = require('../../wxParse/wxParse.js');  page({...})

4)在js文件里面解析获取的纯html字符串,注意:这里必须得是字符串(如:'

2112

 

wx.request({

url:'https://m.*****.com/index.php/Home/Xiaoxxf/activity_detail?a_id='+options.id,//含富文本html

data:{

is_detail:1

},

method:'GET',

header:{

'Content-Type':'application/json'

},

success:function(res){

that.setData({

Article: res.data //一维数组json编码后对象,全部数据

})

 

/**

* html解析

*/

var article = that.data.Article;

console.log("article = "+ article);