本篇博客我们来学习一下Dojo开发中常用到的布局容器BorderContainer和堆叠容器的使用。
1、BorderContainer
它是一个布局容器,主要分为5个区域,上下左右中。每个BorderContainer都有两种不同的方式布局,可以通过“design”属性来控制,分别为headline和sidebar,布局方式如下图所示:
2、堆叠容器
当页面中的内容比较多的时候,可以使用堆叠容器显示部分元素,主要有3种类型:
StackContainer最普通的一种,需要自己编写控制和代码。
TabContainer按钮在前端一字排开。
3、示例代码
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>dojo之BorderContainer和堆叠容器</title> <style type="text/css"> html,body { width: 100%; height: 100%; margin: 0; overflow: hidden; } #borderContainer { width: 100%; height: 100%; } </style> <script type="text/javascript"> dojoConfig = { parSEOnLoad: true }; </script> <link href="Scripts/dijit/themes/claro/claro.css" rel="stylesheet" /> <script type="text/javascript" src="Scripts/dojo/dojo.js"></script> <script type="text/javascript"> require(["dojo/parser","dijit/layout/ContentPane","dijit/layout/BorderContainer","dijit/layout/TabContainer","dijit/layout/AccordionContainer","dijit/layout/AccordionPane"]); </script> </head> <body class="claro"> <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="gutters:true,liveSplitters:false" id="borderContainer"> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top',splitter:false" style="background-color: grey"> 合肥市防汛抗旱综合应用系统 </div> <div data-dojo-type="dijit/layout/AccordionContainer" data-dojo-props="minSize:20,region:'right',splitter:true" style="width: 300px;" id="leftAccordion"> <div data-dojo-type="dijit/layout/AccordionPane" title="汛情概览"> </div> <div data-dojo-type="dijit/layout/AccordionPane" title="实时雨情"> </div> <div data-dojo-type="dijit/layout/AccordionPane" title="汛情预警" selected="true"> </div> <div data-dojo-type="dijit/layout/AccordionPane" title="实时水情"> </div> </div> <div data-dojo-type="dijit/layout/TabContainer" data-dojo-props="region:'center',tabStrip:true"> <div data-dojo-type="dijit/layout/ContentPane" title="系统首页" selected="true"> 系统首页</div> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="closable:true" title="实时视频"> 实时视频</div> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="closable:true" title="水利工程"> 水利工程</div> </div> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'" style="background-color: red"> 暖枫无敌2015 @版权所有 当前时间:2015年12月15日 星期二 </div> </div> </body> </html>
原文链接:https://www.f2er.com/dojo/290979.html