1

我第一次使用editor.js,我被困在这部分:从我的画廊中选择图像后,我想用新图像重新渲染编辑器js:这是我现在的代码

let url = `/${this.selectedImg.image.id}/${this.selectedImg.image.name}`
  this.editor.configuration.data.blocks.push({
    data: {
      caption: "",
      file: {url: url},
      stretched: false,
      withBackground: false,
      withBorder: false,
    },
    type: "image"
  })
  console.log(this.editor,'editor')
  this.editor.render()

this.editor.render()不起作用,我错过了什么?这是console.log 截图

我将不胜感激任何帮助!

4

1 回答 1

1
 editor.save().then((data) => {
     data.blocks.push({
       type: "image",
       data: {
         caption: "",
         file: {url: url},
         stretched: false,
         withBackground: false,
         withBorder: false,
       },
     })
     this.editor.render(data)
     this.$emit('close', true)
   })

这就是答案,我误读了文档:)

于 2021-04-17T23:03:35.727 回答