当我运行我的应用程序时出现错误`
"Uncaught TypeError: object is not a function", source: file:///android_asset/www/js/controller.js (2)
我有一个 model.js 类:
var posAttuale = {
myLat : "myLat",
myLng : "myLng",
myComune : "myComune"
};
和一个类controller.js:
var infoPos = new posAttuale; //Error is here
//....rest of program....
如何修复该错误?
`
最佳答案
您需要将其作为构造函数调用,并将其定义为构造函数:
var posAttuale = function() {
this.myLat = "myLat";
this.myLng = "myLng";
this.myComune = "myComune";
};
var infoPos = new posAttuale();
关于javascript - 对象不是函数(MVC Javascript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30911463/