我有一个Java类,说“ myjavascript.js”。我有以下课程:
var myClass= function () {
this.property2 = '';
this.property3 = '';
this.property4 = '';
this.property5 = '';
this.say() = function () {
alert('Say Hello');
}
我有一个在某些事件上触发的功能。
function myFunction(){
var myClassObj= new myClass();
myClassObj.property2 = 'property2' ;
myClassObj.property3 = 'property2' ;
myClassObj.property4 = 'property2' ;
myClassObj.property5 = 'property2 ';
myClassObj.say();
}
关于触发功能,我得到这个错误
未捕获的TypeError:undefined不是函数
请记住,两者都在同一个文件中。
this.say()
是错误。您正在调用该函数,而不是对其进行定义。
this.say = function () {
alert('Say Hello');
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句