我需要validateText
函数调用modalFunc
。我怎样才能做到这一点?在同一对象中用其他方法调用对象的方法
function geoAlert(lodash) {
var me = this;
return {
modalFunc: function(text) {
alert(text);
},
validateText: function() {
modalFunc("hello")
}
}
}
当我运行:
geoAlert.validateText();
我会得到这个错误:
ReferenceError: modalFunc is not defined
使用me.modalFunc("hello")
没有工作过。请提前帮助和感谢。
这取决于如何调用validateText。看起来像你主要只是需要了解这个''在JS中如何工作。 – 2016-12-29 17:56:08