在创建新的Editor实例时,在onInit方法中设置editorView的值时遇到问题。因为调用嵌套了两个方法,所以我不确定如何访问Vue实例来正确设置editorView。
data: function() {
return {
editor: new Editor({
onInit: ({ state, view }) => {
this.editorView = view
},
}),
editorView: null,
}
},发布于 2020-07-27 22:21:46
我发现了一个名为tiptap的库,根据它的events,您可以这样做:
data: function() {
return {
editor: new Editor(),
editorView: null,
}
},
mounted(){
this.editor.on('init', ({ state, view }) => {
this.editorView = view
})
}或
data: function() {
return {
editor: null,
editorView: null,
}
},
mounted(){
let that=this;
this.editor=new Editor({
onInit: ({ state, view }) => {
that.editorView = view
},
})
}由于this引用的是Editor实例而不是Vue实例
https://stackoverflow.com/questions/63116758
复制相似问题