为什么这里抛出了一个错误?我有点费解,求解答。

Item.prototype.add = function ( child ) {        // 在子元素容器中插入子元素
        this.children.push ( child );        // 插入到当前组件元素树上
        this.element.appendChild( child.getElement() );        return this;
    };
    Item.prototype.getElement = function () {        return this.element;
    };

Uncaught TypeError: child.getElement is not a function
这是怎么回事呢?


慕田峪7331174
浏览 459回答 1
1回答

猛跑小猪

你传入的child 的原型链上层没有有getElement方法, 有可能是child没有关联上Item.prototype。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript