나는이 질문이 이미 StackOverflow에 게시되었음을 알고 있지만 이해가 안되었거나 다소 변경되었습니다.Sencha Touch 2 전역 변수 - 액세스 사방
내 앱이 로그인 용 양식 패널을로드 한 다음 방금 로그온 한 사용자 정보를 저장하려고합니다. 이렇게하면 언제든지 로그인 한 사용자의 이름을 알 수 있으며 언제든지 내보기를 변경할 수 있습니다.
여기 내 주요 코드 :
//<debug>
Ext.Loader.setPath({
'Ext': 'sdk/src'
});
//</debug>
Ext.application({
name: 'APP',
loadedUser: 'the test',
requires: ['Ext.MessageBox'],
views: ['Main', 'Home', 'Login'],
models: ['User'],
stores: ['Users'],
controllers: ['Main'],
icon: {
57: 'resources/icons/Icon.png',
72: 'resources/icons/Icon~ipad.png',
114: 'resources/icons/[email protected]',
144: 'resources/icons/[email protected]'
},
phoneStartupScreen: 'resources/loading/Homescreen.jpg',
tabletStartupScreen: 'resources/loading/Homescreen~ipad.jpg',
setLoadedUser: function(arg) {
this.loadedUser = arg;
},
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the main view
Ext.Viewport.add(Ext.create('APP.view.Main'));
},
onUpdated: function() {
Ext.Msg.confirm("Application Update", "This application has just successfully been updated to the latest version. Reload now?", function() {
window.location.reload();
});
}
});
'loadedUser'의 I는 그 값을 변경 suposed 내 전역 변수와 메소드 setLoadedUser (ARG)로 원하는 것을.
'loadedUser'에 액세스 할 수 있지만 아무런 문제가 없지만 값을 변경할 수는 없습니다. 또 다른 질문 : loadedUser는 배열/데이터 구조 일 수 있습니까?
어떻게 함수에 액세스합니까? 이것은 나를 위해 작동합니다. 'APP.app.setLoadedUser ('test');'와 같이 접근해야한다는 것을 기억하십시오. 그리고 네, 어떤 가치가있을 수 있습니다. :) – rdougan
그것은 그 것이었다. 답으로 제출하여 답변을 드릴 수 있습니다 :) 감사합니다. – Ricardo