我第一次使用 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 screenshot
如果有任何帮助,我将不胜感激!
最佳答案
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)
})
这就是答案,我误读了文档:)
关于javascript - 如何从 editor-js 手动渲染数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67143629/