我在 Sencha Touch 中有一个视图,我通过初始化函数填充了该视图。这是代码:
Ext.define("Pycsell.view.Home", {
extend: "Ext.form.Panel",
requires: "Ext.form.FieldSet",
alias: "widget.homepage",
config:{
scrollable: false,
cls: 'splash_screen',
layout: 'vbox'
},
initialize: function () {
this.callParent(arguments);
var fb_login = {
xtype: 'button',
cls: 'fb_login_button'
};
var tradreg = {
xtype: 'button',
cls: 'tradreg_button'
};
var tradlog = {
xtype: 'button',
cls: 'tradlog_button'
};
var logo_container = Ext.create('Ext.Panel', {
cls: 'logo_container',
width: '90%',
flex: 4,
});
var button_container = Ext.create('Ext.Panel', {
cls: 'splash_content',
items: [fb_login, tradreg, tradlog],
flex: 2,
});
this.add([
logo_container,
button_container
]);
this.setButtonSizes();
},//End init
setButtonSizes: function() {
console.log('Width is:' + $('.fb_login_button').width());
console.log('Old height is:' + $('.fb_login_button').height());
var height = $('.fb_login_button').width()*0.29;
$('.fb_login_button').height(height);
console.log('New height is:' + $('.fb_login_button').height());
}
});
现在,setButtonSizes 函数确实触发了,但是所有的值都是空的,这让我相信这些项目在它被调用时实际上并没有被初始化。我将如何正确执行此操作以便实际设置值?提前致谢。