在管理系統中,管理菜單的界面是固定的,會變化的只是中間的部分。我就在想,是否是跟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
頁面