Javascript 我在load prototype中调用了一个hello原型,但它说未定义的ot hello不是一个函数
我在load prototype中调用了一个hello原型,但它说未定义的ot hello不是一个函数Javascript 我在load prototype中调用了一个hello原型,但它说未定义的ot hello不是一个函数,javascript,Javascript,我在load prototype中调用了一个hello原型,但它说未定义的ot hello不是一个函数 function Myfunc(){} Myfunc.prototype.load = function(){ let html =`hello i am ${this.hello()}` return html; } Myfunc.prototyoe.hello= function(){ let head =`i am foo` return head; } 除了明显的
function Myfunc(){}
Myfunc.prototype.load = function(){
let html =`hello i am ${this.hello()}`
return html;
}
Myfunc.prototyoe.hello= function(){
let head =`i am foo`
return head;
}
除了明显的打字错误之外,您忘记了实例化构造函数 函数Myfunc{} Myfunc.prototype.load=函数{ 让html=`你好,我是${this.hello}` 返回html; } Myfunc.prototype.hello=函数{ 我是福` 回流头; } //您需要实例化Myfunc const func=新的Myfunc;
console.logfunc.load;打字错误Myfunc。prototyoe@nircraft如果一个问题包含代码输入错误,应该由作者来更正。不是编辑。打字错误可能是全部问题,明白了。谢谢你让我知道。我之前实例化了Myfunc,但它不起作用