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