下载wxParse包,注意:编辑器中图片要进行全局处理,确保图片是可以显示的路径
处理编辑器数据中的图片问题
$result = $this->service->getGoodsDetails($data,$field);
if (!empty($result['goods_content'])){
$result['goods_content'] = str_replace( '/public/upload/' , config('shop_domain').'/public/upload/' , $result['goods_content']
);
}
*在小程序js文件中引入wxParse *
let wxparse = require("../../wxParse/wxParse.js");
Page({
setGoodsDetailsValue: function(data) {
var that = this;
that.setData({
goodsDetails: data,
goodsPrice: data.shop_price,
goodstotalPrice: data.shop_price,
});
wxparse.wxParse('dkcontent', 'html', data.goods_content, that, 5);
},
})
小程序html页面引入模板文件
<import src="../../wxParse/wxParse.wxml" />
<view class='content'>
<template is="wxParse" data="{{wxParseData:dkcontent.nodes}}" />
</view>