课程表

Ext.js课程

工具箱
速查手册

Ext.js 容器内的容器

当前位置:免费教程 » JS/JS库/框架 » Ext.js

描述

容器内部容器:我们可以在其他容器内部的容器作为父容器的组件以及其他组件。

语法

这里是使用容器内容器的简单语法:

  1. var container = Ext.create('Ext.container.Container', {
  2. items: [component3, component4]
  3. });
  4. Ext.create('Ext.container.Container', {
  5. renderTo: Ext.getBody(),
  6. items: [container]
  7. });

您可以将容器作为其他容器中的项目

下面是一个简单的例子,显示容器内的容器:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link href="//cdn.bootcss.com/extjs/6.2.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
  5. <script type="text/javascript" src="//cdn.bootcss.com/extjs/6.2.0/ext-all.js"></script>
  6. <script type="text/javascript">
  7. Ext.onReady(function () {
  8. var component1 = Ext.create('Ext.Component', {
  9. html:'First Component'
  10. });
  11. var component2 = Ext.create('Ext.Component', {
  12. html: 'Second Component'
  13. });
  14. var component3 = Ext.create('Ext.Component', {
  15. html: 'Third Component'
  16. });
  17. var component4 = Ext.create('Ext.Component', {
  18. html: 'Fourth Component'
  19. });
  20. var container = Ext.create('Ext.container.Container', {
  21. style: {borderStyle: 'solid', borderWidth: '2px' },
  22. width: '50%',
  23. items: [component3, component4]
  24. });
  25. Ext.create('Ext.container.Container', {
  26. renderTo: Ext.getBody(),
  27. title: 'Container',
  28. border: 1,
  29. width: '50%',
  30. style: {borderStyle: 'solid', borderWidth: '2px' },
  31. items: [component1, component2, container]
  32. });
  33. });
  34. </script>
  35. </head>
  36. <body>
  37. </body>
  38. </html>

尝试一下

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号