bootstrap+vue实现信息的增删改查

主要是对bootstrap和vue的基本用法进行一个练习,代码奉上

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>信息管理系统</title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
		<script src="js/jquery-1.10.1.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			
			#container{
				padding: 0 100px;
			}
			h2,h5,label,h3{
				font-weight: 700;
			}
			h3{
				color: #3071A9;
			}
			.radio1{
				background: #fff;
			}
			table{
				text-align: center;
			}
			th{
				text-align: center;
				color: #A94442;
			td{
				color: #000;
			}
		</style>
	</head>
	<body>
		<div class="out" id="container">
			<h2>信息管理系统</h2>
			<div>
			  <div class="form-group">
			    <label for="username">姓名</label>
			    <input type="text" class="form-control" id="username" placeholder="请输入姓名" v-model="name">
			  </div>
			  <div class="form-group">
			    <label for="age">年龄</label>
			    <input type="text" class="form-control" id="age" placeholder="请输入年龄" v-model="aage">
			  </div>
			  <div class="form-group">
			    <label for="exampleInputFile">职位</label>
			    <select class="form-control" v-model="enginer">
				  <option>ios工程师</option>
				  <option>H5工程师</option>
				  <option>Java工程师</option>
				  <option>UI设计师</option>
				</select>
			  </div>
			  <div class="checkbox">
			    <h5 >性别</h5>
			     	男: <input v-model="sex" class="radio1" type="radio" name="sex" value="男">
			    	女: <input v-model="sex" class="radio1" type="radio" name="sex" value="女">
			  </div>
			  <button  class="btn btn-info" v-on:click="add($event)">添加</button>
			  <button  class="btn btn-danger" @click="chongz($event)">重置</button>
			</div>
			<h3>用户信息表</h3>
			<table class="table table-bordered">
					<tr>
						<th>序号</th>
						<th>姓名</th>
						<th>信息</th>
						<th>操作</th>
						<th>操作</th>
					</tr>
					<tr v-for="(item,i) in arr">
						<td>{{i}}</td>
						<td>{{item.name}}</td>
						<td>
							<button class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat" @click="chakan(i,item)">查看</button>
						</td>
						<td>
							<button class="btn btn-danger" v-on:click="dele(i)">删除</button>
						</td>
						<td>
							<button class="btn btn-warning" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat" @click="chakan(i,item)">修改</button>
						</td>
					</tr>
			</table>
			<!--查看的模态框-->
			<div id="look">

				<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
					  <div class="modal-dialog" role="document">
						<div class="modal-content">
						  <div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							<h4 class="modal-title" id="exampleModalLabel">个人信息</h4>
						  </div>
						  <div class="modal-body">
							  <div class="form-group">
								<label for="recipient-name" class="control-label">姓名:</label>
								<input type="text" class="form-control" id="recipient-name" v-model="n">
							  </div>
							<div class="form-group">
								<label for="recipient-name1" class="control-label">年龄:</label>
								<input type="text" class="form-control" id="recipient-name1" v-model="a">
							  </div>
							  <div class="form-group">
								<label for="recipient-name2" class="control-label">职位:</label>
								<input type="text" class="form-control" id="recipient-name2" v-model="e">
							  </div>
							  <div class="form-group">
								<label for="recipient-name3" class="control-label">性别:</label>
								<input type="text" class="form-control" id="recipient-name3" v-model="s">
							 </div>
						  </div>
						  <div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-primary" data-dismiss="modal" @click="xiugai()">确定</button>
						  </div>
						</div>
					  </div>
				</div>
				
			</div>
		</div>	
		<script src="js/jquery-1.10.1.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var vm = new Vue({
				el:".out",
				data:{
					name:"",
					aage:"",
					enginer:"",
					sex:"",
					arr:[],
					n:"",
					a:"",
					e:"",
					s:"",
					index:""
				},
				methods:{
					add(e){
						this.arr.push({name:this.name,age:this.aage,enginer:this.enginer,sex:this.sex});
						this.name="";
						this.aage="";
						this.enginer="";
						this.sex=""
					},
					chongz(e){
						this.name="";
						this.aage="";
						this.enginer="";
						this.sex=""
					},
					dele(i){
						this.arr.splice(i,1)
					},
					chakan(i,item){
//						var index ="";
						this.n=item.name;
						this.a=item.age;
						this.e=item.enginer;
						this.s=item.sex;
//						return index=i;
						index=i
					},
					xiugai(){
//						console.log(this.arr[index])
						this.arr[index].name = this.n;
						this.arr[index].age = this.a;
						this.arr[index].enginer = this.e;
						this.arr[index].sex = this.s;
//						this.arr.splice(i,1,{name:item.name})
					}
				}
			})
		</script>
	</body>
</html>

注:文件的话,可以去官网下载,也可以去bootcdn去引入一下。

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值