0

我有一个EditNote继承自的类ViewNote,问题是每当我尝试访问super.removeElement('bible-close')(这是超类中的方法)时,我都会得到一个TypeErrorUncaught TypeError: Cannot read property 'call' of undefined

class ViewNote {
    constructor() {
        let viewNote = document.querySelector('.view-note');
        let viewNoteParent = document.querySelector('.bible-view-note-list');

        this.viewNote = () => viewNote;
        this.viewNoteParent = () => viewNoteParent;
    }
    removeParentElement(el) {

       this.viewNote().removeAttribute('style');

       Array.from(
           this.viewNote().querySelectorAll('.bible-view-note-item'),
           el => el.remove()
       );

    }

}

class EditNote extends ViewNote {

    constructor() {
        super();


        super.showNote({
            editwidget: true,
            listener({content, title, creationDate}, ...args) {
                for (let i of args) {
                    i.addEventListener('click', e => {
                        let target = e.target;

                        if (target.className.includes('bible-close')) {
                            super.removeElement('bible-close');
                            return ;
                        }

                    })
                }
            }
        });
    }
}    

上面代码的问题是super.removeParentElement('bible-close');抛出一个TypeError. 我什至尝试使用this关键字,但它不起作用,因为在方法this内部未定义super.showNote

4

0 回答 0