关于抽象类中继承的问题
老师的代码可能有点错误但意思应该没错,我的理解是这样的:
function Base(){ throw new Error('直接执行我没用!'); } Base.det = function(){console.log('det');}; Base.stop = function(){console.log('stop');}; Base.init = function(){console.log(23);}; Base.prototype.fun = function(){console.log('prototype_fun');}; function link(){} link.prototype = Object.create(Base);//这里我想应该是将Base对象作为继承吧; link.prototype.constructor = link; link.det = function(){console.log('link.det');}; link.prototype.init = function(){console.log('link.init');}; Base.det();//‘det' link.det();//'link.det' var ink = new link(); ink.det();//'det' ink.init();//'link.init' ink.fun();//会报错,说这不是一个function //如果这里能被执行必须修改Object.create(Base.prototype);
..............................