Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Tianium框架创建全局阵列_Javascript_Android_Multidimensional Array_Global Variables_Titanium Alloy - Fatal编程技术网

Javascript 使用Tianium框架创建全局阵列

Javascript 使用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

我有三个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){
    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();