1.0.1 • Published 6 months ago

sy-editor-wxapp v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

索易编辑器小程序版

使用步骤

  1. 安装
npm i sy-editor-wxapp
  1. 引入
{
  "usingComponents": {
    "sy-editor": "sy-editor-wxapp/syeditor/index",
    "sy-editor-view": "sy-editor-wxapp/syeditorview/index"
  }
}
  1. 使用
<sy-editor list="{{ list }}" editorType="{{ editorType }}" uploadUrl="{{ uploadUrl }}" uploadToken="{{ uploadToken }}" bind:update="handleUpdate" bind:request="handleRequest"></sy-editor>
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [{ type: 'text', value: '' }], // 初始数据
    editorType: ['text', 'image', 'video', 'file'], // 类型声明
    uploadUrl: 'https://xxxx/upload', // 上传服务器地址
    uploadToken:  'token'// token
  },

  // 子组件数据传递 - 触发视图更新
  handleUpdate(e) {
    this.setData({ list: e.detail })
  },
  // 子组件上传事件
  handleRequest(e) {
    // res 上传结果, index 当前数组下标
    const { index, res } = e.detail
    const str = 'list[' + index + '].value'
    this.setData({ [str]: JSON.parse(res.data).url })
  },
})