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
这是怎么回事呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你传入的child 的原型链上层没有有getElement方法, 有可能是child没有关联上Item.prototype。
在你
这行代码之前加一行代码: