将重复的view页面复用
页面布局layout使用流程
- 先有个外部框架
- 把页面重复部分删掉
- 把框和主页面结合起来
控制器的设置:
渲染
this.Layout = "框.html"
this.TplName = "嵌入内容.html"
在layout框中指定嵌入内容的位置
{{.LayoutContent}}
嵌入的内容
<div class="main_body" id="main_body"...>
LayoutSection
当一个LayoutContent不够时,可以通过LayoutSection在 Layout 页中设置多个 section
控制器中:
this.Layout = "layout.html"
this.LayoutSections = make(map[string]string)
this.LayoutSections["indexJs"] = "indexJs.html"
layout中指定嵌入内容的位置
{{.indexJs}}
嵌入的内容
<script type="text/javascript">
window.onload = function (ev) {
//找标签 触发了什么事件 实现什么功能
$(".dels").click(function () {
if(!confirm("是否确认删除?")){
return false
}
})
$("#select").change(function () {
//让form发个请求
$("#form").submit()
})
}
</script>