[英]How to use values from this array? Ext-JS 4
因此,當我放入console.log(Test.globals.user)
我得到了:
[id: "1", first_name: "MyFirstName", last_name: "MyLastName"]
如何獲得名字和姓氏的值? 我已經試過了:
Test.globals.user.first_name //undefined
Test.globals.user[first_name] //error - no first_name variable provided
Test.globals.user["first_name"] //undefined
謝謝。 :)
Ext的實現方式是擁有一個單例類來容納全局的,應用程序范圍內的var:
Ext.define('Test.globals', {
singleton: true,
user: {
id: 1,
first: 'Foo',
last: 'Bar'
}
});
Ext.onReady(function(){
console.log(Test.globals.user.first);
});
不是Ext示例
var Test = {
globals: {
user: {
first: 'Foo'
}
}
};
您可以嘗試Test.globals.user [1] .first_name嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.