1

1 つのビュー全体で変数をグローバルにしようとしていますが、できませんでした。

initialize : function(){
    this.callParent();

    this.nameValue=0;
if(name="ram")
    this.nameValue=1;
     console.log("Test 1 -"+this.nameValue);
}else {
 this.nameValue=0;
     console.log("Test 2 -"+this.nameValue);
}

}

次のようなアクセス値フォーム ボタン タップになります。

onSubmitButtonTap: function () {
 console.log("Button Tap Here");
 console.log("Test Def-6-"+this.nameValue);
}

しかし、私はそれにアクセスできませんでした。常に 0 と表示されます。グローバル変数が正常に機能しませんでした。

4

1 に答える 1

2

次のように自動セッター/ゲッターを使用できます。

config: {
    nameValue: 0,

    listeners: {
        initialize : function() {
            if (name="ram") {
                this.setNameValue(1);
                console.log("Test 1 -" + this.getNameValue() );
            } else {
                this.setNameValue(0);
                console.log("Test 2 -" + this.getNameValue() );
            }
        }
    }
},

onSubmitButtonTap: function () {
    console.log("Button Tap Here");
    console.log("Test Def-6-" + this.getNameValue() );
}
于 2013-08-07T06:03:09.687 に答える