收藏
回答

使用editor组件向后台提交html内容时,后台无法解析?

希望各位大佬帮帮忙

//发布动态
          if (res.confirm) {
            var outfile = '';
            console.log(files);
            if(files!=undefined)
            {
              if (files.length > 0) {
                for (var file in files) {
                  if (outfile == '') {
                    outfile = files[file];
                  }
                  else {
                    outfile += ',' + files[file];
                  }
  
                }
              }
            }
            
            console.log(outfile);
            // const pub = PubContent.replace(/\"/g,"'");
            const pub = PubContent.replace(/wx:nodeid="\d+"/g,'');
            const content = pub.replace(/\"/g,"'");
            // const con = content.replace(/=/g,":");
            let data = {
              'UserName''ycl',
              'ApprovalFlag'1,
              'Title': title,
              'PubContent': content,
              'UploadFile': outfile,
              'ShortDes': ShortDes
            };
            //var abc = JSON.stringify(data).toString().replace(new RegExp("\\\\\"","gm"),"\"");
            // var a = abc.PubContent
            console.log(JSON.stringify(data));
            api.community.publish(JSON.stringify(data), (state, result) => {
              console.log(state, result);
              if (state == 'success' && result.data.StatusCode == 1000) {
                wx.showToast({
                  title: '发布成功',
                  duration:1500,
                })
              } else {
                wx.showModal({
                  title: '提示',
                  content: '发布失败',
                  showCancel: false
                })
              }
            })

回答关注问题邀请回答
收藏

1 个回答

  • 吕氏
    吕氏
    06-15

    我们是后台添加html文章,小程序解析。

    小程序的结构比较简单,无非【图片】-【文字】-【图片】我们一般都结构化了

    06-15
    有用 1
    回复
登录 后发表内容
问题标签