Home

Awesome

⚠️ 太久没空更新,不确定是否可用

xing-weapp-editor

开箱即用的小程序图文编辑组件

代码片段

https://developers.weixin.qq.com/s/adp5u9mk7H6w

效果预览

组件属性

属性名类型默认值说明
image-upload-urlString图片上传,必填,参考wx.uploadFile
image-upload-nameString图片上传,必填,参考wx.uploadFile
image-upload-headerString图片上传,参考wx.uploadFile
image-upload-form-dataObject图片上传,参考wx.uploadFile
image-upload-key-chainString图片上传接口返回值中url字段的路径,如返回为{ image : { url: 'http://xxx.jpg' } },则填image.url
output-typeStringhtml输出的格式,htmlarray,参考rich-text
button-background-colorString#409EFF完成按钮的背景色
button-text-colorString#fff完成按钮的前景色
nodesArray初始内容的array形式,仅支持此组件输出的array,优先于HTML
htmlString初始内容的HTML形式,仅支持此组件输出的HTML
bindfinishEventHandle输出内容时触发,event.detail = { content }

代码示例

<!-- index.wxml -->
<xing-editor
  bindfinish="finish"
  output-type="html"
  image-upload-url="http://localhost:3000/upload"
  image-upload-name="image"
  image-upload-key-chain="image.url"
  html="{{html}}"/>
//index.js
Page({
  data: {
    html: '<p class="xing-p">123124<br><br>123124123<br><br><br>324123</p>' +
    '<img class="xing-img" style="width: 100%" src="http://localhost:3000/static/73e95bd90f005.png" _height="0.5743348982785602" _uploaded="true"></img>' +
    '<p class="xing-p">333</p>' +
    '<img class="xing-img" style="width: 100%" src="http://localhost:3000/static/2dab4bd82f879.png" _height="1.2095588235294117" _uploaded="true"></img>',
  },

  finish: function (e) {
    console.log(e.detail.content);
  },
})
{
  "usingComponents": {
    "xing-editor": "/components/xing-editor"
  }
}

TODO List