Javascript 使用Tianium框架创建全局阵列
我有三个js控制器文件和一个库 app/lib/ClientJavascript 使用Tianium框架创建全局阵列,javascript,android,multidimensional-array,global-variables,titanium-alloy,Javascript,Android,Multidimensional Array,Global Variables,Titanium Alloy,我有三个js控制器文件和一个库 app/lib/Client function Client(id,name,blc){ this.id=id; this.name=name; this.blc=blc; }; Client.prototype.getName = function(){ return this.id+' '+this.name+' '+this.blc; }; Client.prototype.withdraw = function(amount
function Client(id,name,blc){
this.id=id;
this.name=name;
this.blc=blc;
};
Client.prototype.getName = function(){
return this.id+' '+this.name+' '+this.blc;
};
Client.prototype.withdraw = function(amount){
if(amount<0) return -1;
if(this.blc<amount) return -1;
return this.blc-=amount;
};
Client.prototype.deposite = function(amount){
if(amount<0) return -1;
return this.blc+=amount;
};
module.exports = Client;
功能客户端(id、名称、blc){
这个.id=id;
this.name=name;
这个.blc=blc;
};
Client.prototype.getName=函数(){
返回this.id+''+this.name+''+this.blc;
};
Client.prototype.draw=函数(金额){
如果(数量如果你真的想要一个“全局数组”使用
如果需要模型集合,请使用
var args = arguments[0] || {};
var Client = require('Client');
function doClick(e) {
var user_id = $.id.getValue();
var user_name = $.name.getValue();
var user_blc = $.Balance.getValue();
if(user_id.length<=0 && user_name.length<=0 && user_blc.length<=0){
alert('you entred an invalid information');
}
else{
var c = new Client(user_id,user_name,user_blc);
alert(c.getName()+' is add successfly');
//note!!!!!
//add a global array to save the data
$.id.setValue("");
$.name.setValue("");
$.Balance.setValue("");
}
}
$.addClient.open();