gpt4 book ai didi

javascript - extjs 示例代码不起作用

转载 作者:行者123 更新时间:2023-11-30 13:08:49 25 4
gpt4 key购买 nike

Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
width: 400,
height: 300,
title: 'Container Panel',
items: [
{
xtype: 'panel',
title: 'Child Panel 1',
height: 100,
width: '75%'
},
{
xtype: 'panel',
title: 'Child Panel 2',
height: 100,
width: '75%'
}
]
});

上面的代码没有被执行...请你找出错误或错误。我对 extjs 很陌生。我在浏览 documentaion 时发现了上面的代码(检查“容器”部分)。它在 jsfiddle 中执行良好但不在我的项目中。(其他示例在我的项目中运行良好)。

回答:

Ext.onReady(function(){
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
width: 400,
height: 300,
layout: 'hbox',
title: 'Container Panel',
items: [
{
xtype: 'panel',
title: 'Child Panel 1',
height: 100,
flex:1
},
{
xtype: 'panel',
title: 'Child Panel 2',
height: 100,
flex:1
}
]
});
});

最佳答案

几个问题:

1) 您需要将代码包装在 onReady block 中。

2) 宽度无效。怎么可能都是75%呢?在这种情况下,您需要使用 hbox 布局,每个子项都是 flex: 1。

关于javascript - extjs 示例代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14641808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com