1 模板继承
```
{extend name="base" /}
```
2 模板包含
```
{include file='模版文件1,模版文件2,...' /}
```
3
```
<script type="text/javascript">
$(function(){
$('.del').click(function(){
var url = $(this).attr('link');
layer.confirm('你确定要此操作吗?', {
icon: 5,
btn: ['确定','取消'] //按钮
}, function(){
$.get(url,function(data){
if (data.code == 1) {
layer.alert(data.msg, {icon: 6},function (index) {
layer.close(index);
window.location.reload();
});
}else{
layer.alert(data.msg);
}
});
});
});
$('.logout').click(function(){
var url = $(this).attr('link');
layer.confirm('你确定要此操作吗?', {
icon: 5,
btn: ['确定','取消'] //按钮
}, function(){
$.get(url,function(data){
if (data.code == 1) {
layer.alert(data.msg, {icon: 6},function (index) {
layer.close(index);
window.location.reload();
});
}else{
layer.alert(data.msg);
}
});
});
});
});
</script>
```
4 表单提交数据
```
{block name="js"}
<script type="text/javascript">
$(function () {
$("form").submit(function(e){
$.ajax({
url: "{:url('Category/save')}",
data: $(this).serialize();
type: 'post',
success:function(data){
if (data.code == 1) {
layer.msg(data.msg,{icon:6},function (index) {
layer.close(index);
window.location.href = "{:url('index')}";
});
} else{
layer.msg(data.msg,{icon:5},function (index) {
layer.close(index);
window.location.reload();
});
}
}
});
return false; // 阻止表单跳转
});
});
</script>
{/block}
```