在管理系统中,管理菜单的界面是固定的,会变化的只是中间的部分。我就在想,是否是跟angular的“组件模块的router-outlet同样”每次只用修改中间的内容部分,菜单和导航栏不变。html
果不其然,beego框架也是支持layout的设计。框架
layout.html
,这个html文件中把整个的页面框架设计好,在须要替换的内容的地方写成{{.layoutContent}}<div> <!-- Content Header (Page header) --> {{.ContentHead}} <!-- Main content --> {{.LayoutContent }} </div>
func (this *Usercontroller)Get() { this.Data["Title"] = "用户管理" this.Layout = "layout.html" this.LayoutSections = make(map[string]string) this.LayoutSections["CustomJs"] = "customjs/user.html" this.LayoutSections["CustomCss"] = "" this.LayoutSections["ContentHead"] = "contenthead2.html" this.LayoutSections["Menu"] = "menu.html" this.TplName = "user.html" this.Data["undesgin"], _ = mgo.Listuser()
layout.html
文件。展现user.html
页面