{Nativescript}在模型中添加更多属性
我是nativescript的新手。目前,我正在我的customer-view-model.js中创建一个包含2个属性的应用程序,如下所示,运行良好{Nativescript}在模型中添加更多属性,nativescript,Nativescript,我是nativescript的新手。目前,我正在我的customer-view-model.js中创建一个包含2个属性的应用程序,如下所示,运行良好 function Customer( nama ) { this.nama = nama; this.complete = false; } module.exports = Customer; 当我在下面添加更多属性(如代码)时,我的应用程序抛出一个错误,消息为ReferenceError:telpon未定义 fun
function Customer( nama ) {
this.nama = nama;
this.complete = false;
}
module.exports = Customer;
当我在下面添加更多属性(如代码)时,我的应用程序抛出一个错误,消息为ReferenceError:telpon未定义
function Customer( nama ) {
this.nama = nama;
this.telpon = telpon;
this.complete = false;
}
module.exports = Customer;
我不知道我错过了什么。请帮助:)您从第一行的参数中得到了“nama”,这就是为什么第一行是好的,但不是telpon,所以如果它的输入参数需要添加到第一行(作为定义),或者使用函数中3行的内容将变量设置为某个默认值
这是模型的属性,
this.telpon已完成,但您正在将变量分配给未定义的属性
function Customer( nama,telpon ) {
this.nama = nama;
this.telpon = telpon;
//this.telpon = 1;
//this.telpon = "string";
//this.telpon = false/true;
this.complete = false;
}
module.exports = Customer;
非常感谢@Marek,当我使用这个的时候。telpon=telpon;仍然获取错误,但使用this.telpon=1时;一切正常。请再帮忙