我在 ExtJs 中创建了一个类,包括修改类内部属性的变量和函数。
当我想更改类的内部属性(从类的内部或外部函数)时,我的问题集中在。
班上:
var Ws = new Ext.Class({
WsUrl: '',
WsErrorCode: 0,
WsOut: null,
CoreVersion: '',
AppName: '',
AppVersion: '',
BrowserLanguage: GetBrowserLanguage(),
BrowserUserAgent: GetBrowserLanguage(),
BrowserToken: '',
constructor: function(url) {
this.WsUrl = url;
return this;
},
SendCmd: function(CmdName) {
var WsOut;
var WsErrorCode;
//Send request
Ext.Ajax.request({
loadMask: true,
url: this.WsUrl,
params: {cmd: CmdName},
success: function(response, opts) {
WsOut = Ext.decode(response.responseText);
WsErrorCode = response.status;
},
failure: function(response, opts) {
WsOut = Ext.decode(response.responseText);
WsErrorCode = response.status;
}
});
this.WsOut = WsOut;
this.WsErrorCode = WsErrorCode;
return this;
}
});
这里创建了对象:
var WsTest = new Ws('ws.php');
WsTest = WsTest.SendCmd('GetBrowserToken');
alert(WsTest.WsErrorCode); //Here, the code must return 200 but the value is 0 ... why ?
你知道为什么This.WsOut = WsOut
没有正确设置属性吗?