How to pass vue instance to external script?

删除回忆录丶 提交于 2020-03-25 17:36:11

问题


I have this declaration of editor in component vue file:

export default {
    data: function() {
        return {
            editor: new Editor({
                doc: this.value,
                vueInstance: this,
            }),
        }
    },

I am using editor.doc for generating template within contenteditable.

After each keydown event editor.doc should be changed and template should be updated. It means I need change editor.doc kepping reactivity within Editor() external script like this:

vueInstance.$set(this.doc, someKey, someValue);

. That is why I pass vueInstance: this to Editor(). But I get error after doing this.

I get these errors in google chrome :

Uncaught RangeError: Maximum call stack size exceeded 
TypeError: "t is undefined"

and I get these errors in firefox:

[Vue warn]: Error in nextTick: "TypeError: t is undefined"
TypeError: "t is undefined"

How to properly modify editor.doc keeping reactivity? How to pass vue instance to external script if I need so?

来源:https://stackoverflow.com/questions/60727977/how-to-pass-vue-instance-to-external-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!