sy-editor-wxapp

1.0.1 • Public • Published

索易编辑器小程序版

使用步骤

  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 })
  },
})

Package Sidebar

Install

npm i sy-editor-wxapp

Weekly Downloads

3

Version

1.0.1

License

ISC

Unpacked Size

22.6 kB

Total Files

11

Last publish

Collaborators

  • sooyiekj