-
下载wxParse
-
使用
下载成功后解压文件得到
-
例如(我的是用wepy框架)
-
使用(wepy)
html部分
<template>
引入wxParse的wxml文件
<import src="../wxParse/wxParse.wxml"/>
<template is="wxParse" data="{{wxParseData:goodsDesc.nodes}}"></template>
</template>
js部分
//引入js部分
export default class Activity extends wepy.page{
import WxParse from '../wxParse/wxParse'
data={
article: '',
}
onLoad (options) {
this.解析html方法()
}
解析html方法(){
//当请求后台接口成功以后执行如下方法
//goodsDesc页面需要渲染的数据
var temp = WxParse.wxParse('goodsDesc', 'html', res.data.data, that, 0);
that.setData({article: temp})
}
}
css部分
<style lang="less">
@import "../wxParse/wxParse.wxss";
page{
font-size:33rpx;
line-height:2;
}
</style>
ok现在就可以简单使用了,如果你们不需要a标签跳转的话,老弟们还是看看a标签跳转吧,嘤嘤嘤
只需要在当前解析的页面里加入
wxParseTagATap: function(e){
var href = e.currentTarget.dataset.src;
console.log(href);
//我们可以在这里进行一些路由处理
if(href.indexOf(index) > 0){
//跳转的方法根据项目需求的不同自己替换,也可以加参数,
wx.redirectTo({
url: '../index/index'+参数
})
}