【问题标题】:how to manually render data from editor-js如何从 editor-js 手动渲染数据
【发布时间】:2021-07-12 13:35:16
【问题描述】:

我是第一次使用 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.logscreenshot

我将不胜感激!

【问题讨论】:

    标签: javascript vue.js editorjs


    【解决方案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)
       })
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2020-04-08
      • 2018-10-14
      • 2021-03-08
      • 2016-11-13
      • 2016-07-02
      • 1970-01-01
      相关资源
      最近更新 更多