<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{{title}}</title>
<link rel="stylesheet" href="plus/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="css/index.css">
<script src="plus/jquery.min.js"></script>
<script src="plus/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="plus/vue.min.js"></script>
<script src="plus/axios.min.js"></script>
</head> <body>
<div class="container" id="vuechek">
<div class="row">
<div class="col-lg-12">
<form class="form-inline" id="title-form">
<div class="form-group">
<label for="title">标题</label>
<input type="text" class="form-control" id="title" v-model="title" placeholder="请输入标题">
</div>
<button type="button" class="btn btn-default" v-on:click="saveTitle">保存</button>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-12 h3 text-info">章节信息</div>
</div>
<div class="row">
<div class="col-lg-8">
<table class="table table-bordered table-hover text-center">
<tr class="text-info">
<td>#</td>
<td>标题</td>
<td><span class="glyphicon glyphicon-pencil"></span></td>
</tr>
<tr class="text-center" v-for="(item, index) in titles">
<td><span v-text="index+1"></span></td>
<td>
<span v-show="xiugai || item.show" v-text="item.name"></span>
<input v-show="xiugai===false && index===currindex " type="text " v-model="item.name "></input>
</td>
<td> <button v-show="xiugai" type="button " class="btn btn-info btn-sm " v-on:click="updateMsg(index, item) ">修改</button>
<button v-show="xiugai===false && index===currindex" type="button " class="btn btn-info btn-sm " v-on:click="saveMsg(index, item.name) ">保存</button>
<button type="button" v-on:click="newIndex=index" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#layer">删除</button></td>
</tr>
<tr v-show="titles.length!=0">
<td colspan="4" class="text-right"><input type="button" @click="newIndex=-1" data-toggle="modal" data-target="#layer" value="删除全部" class="btn btn-sm btn-danger" /> </td>
</tr>
<tr>
<td colspan="4" class="text-center" v-show="titles.length==0">
暂无数据...
</td>
</tr>
</table>
</div>
</div> <!--模态框-->
<div role="dialog" class="modal fade" id="layer">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal"><span>&times;</span></button>
<h4 class="modal-title">确认删除吗?</h4>
</div>
<div class="modal-body text-right">
<button class="btn btn-primary btn-sm" data-dismiss="modal">取消</button>
<button class="btn btn-danger btn-sm" v-on:click="deleteMsg(newIndex)" data-dismiss="modal">确定</button>
</div>
</div>
</div>
</div> </div>
<!--container-->
</body>
<script>
var app = new Vue({
el: '#vuechek',
data: {
title: '',
titles: [],
newIndex: -100,
currindex: -1,
xiugai: true
},
methods: {
saveTitle: function() {
axios.post('/add', {
title: this.title
})
.then(function(response) {
app.titles.push({
name: response.data,
show: true,
});
})
.catch(function(error) {
console.log(error);
});
},
deleteMsg: function(n) { // alert(n);
if (n == -1) {
this.titles.splice(0, this.titles.length);
}
this.titles.splice(n, 1);
// this.titles.splice(this.newIndex, 1); //也可以
},
saveMsg(index, item) {
this.currindex = -1;
this.xiugai = true;
console.log('我点了保存', index, item);
},
updateMsg: function(n, item) {
item.show = false;
this.currindex = n;
this.xiugai = false;
console.log('我点了 修改', this.msg);
}
}
});
</script> </html>

最新文章

  1. [斜率优化DP]【学习笔记】【更新中】
  2. PHP 版本判断 version_compare() 函数
  3. HTML 基础
  4. EF性能之关联加载
  5. 大型文档源文件拆分编辑编译\include{filename}
  6. python报错
  7. SpringMVC入门1
  8. java中包的应用
  9. spring动画-iOS-备
  10. Android学习总结(十五) ———— Notification(状态栏通知)基本用法
  11. jquery提交form表单插件jquery.form.js
  12. ubuntu下查看-卸载软件(卸载.net core sdk的方法)
  13. Java language
  14. 一文让你熟练掌握Linux的ncat(nc)命令
  15. ios 应用发布渠道大全
  16. linux常用命令:mv 命令
  17. scala中option、None、some对象
  18. Contest2071 - 湖南多校对抗赛(2015.03.28)
  19. idea IDE 导入的项目没有显示目录结构
  20. Sql server字段排序,如果字段是字符型的数字

热门文章

  1. UVA 1262 Password 暴力枚举
  2. C# Activator.CreateInstance 动态创建类的实例(二)
  3. 217. Contains Duplicate【easy】
  4. URL浅谈
  5. java-FileDemo
  6. codeforces 651a oysticks
  7. Chrome插件之一键保存网页为PDF1.1发布
  8. Building Maintainable Software-java篇之Separate Concerns in Modules
  9. java字符串和时间类型的相互转换
  10. jsp中的http status 500错误问题怎么解决