使用Bootstrap和Vue實(shí)現(xiàn)用戶信息的編輯刪除功能
使用Bootstrap實(shí)現(xiàn)簡(jiǎn)單的布局,并結(jié)合Vue進(jìn)行用戶信息的編輯刪除等功能,代碼如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用戶信息編輯</title>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" rel="external nofollow" >
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
<script type="text/javascript" src="vue.js"></script>
</head>
<body>
<div class="container">
<form role="form">
<div class="form-group">
<label for="username">用戶名</label>
<input type="text" name="username" class="form-control" placeholder="請(qǐng)輸入用戶名" v-model="username">
</div>
<div class="form-group">
<label for="password">密碼</label>
<input type="password" name="password" class="form-control" placeholder="請(qǐng)輸入密碼" v-model="password">
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" @click="add()">添加</button>
<button type="reset" class="btn btn-danger">重置</button>
</div>
</form>
<hr>
<table class="table table-bordered table-hover">
<caption class="h3 text-info">用戶信息</caption>
<tr>
<th class="text-center">序號(hào)</th>
<th class="text-center">用戶名</th>
<th class="text-center">密碼</th>
<th class="text-center">操作</th>
</tr>
<tr class="text-center" v-for="item in myData">
<td>{{$index+1}}</td>
<td>{{item.name}}</td>
<td>{{item.password}}</td>
<td>
<button class="btn btn-danger" data-toggle="modal" data-target="#myModal" @click="nowIndex=$index">刪除</button>
</td>
</tr>
<tr v-show="myData.length!=0">
<td colspan="4" class="text-center">
<button class="btn btn-danger" data-toggle="modal" data-target="#myModal" @click="nowIndex=-2">刪除全部</button>
</td>
</tr>
<tr v-show="myData.length==0">
<td colspan="4" class="text-center">
<h5 class="text-muted">暫無信息...</h5>
</td>
</tr>
</table>
<!-- 模態(tài)框 -->
<div class="modal fade" id="myModal" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
<h4 class="modal-title text-danger">警告!</h4>
</div>
<div class="modal-body">
<h4 class="text-center">確認(rèn)刪除?</h4>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-primary">取消</button>
<button type="button" data-dismiss="modal" class="btn btn-danger" @click="deleteMsg(nowIndex)">確認(rèn)</button>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
new Vue({
el: ".container",
data: {
myData:[],
username:"",
password:"",
nowIndex:-100
},
methods:{
add:function(){
this.myData.push({
name:this.username,
password:this.password
});
this.username="";
this.password="";
},
deleteMsg:function(n){
if(n==-2){
this.myData=[];
}else{
this.myData.splice(n,1);
}
}
}
});
</script>
</body>
</html>
實(shí)現(xiàn)效果如下,因?yàn)橹皇呛?jiǎn)單的實(shí)現(xiàn)編輯刪除的功能,因此密碼就直接顯示在表格中,沒有進(jìn)行加密顯示
整體布局界面

用戶信息編輯后添加

刪除數(shù)據(jù)

總結(jié)
以上所述是小編給大家介紹的使用Bootstrap和Vue實(shí)現(xiàn)用戶信息的編輯刪除功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
微信公眾平臺(tái) 客服接口發(fā)消息的實(shí)現(xiàn)代碼(Java接口開發(fā))
這篇文章主要介紹了微信公眾平臺(tái) 客服接口發(fā)消息的實(shí)現(xiàn)代碼(Java接口開發(fā)),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-04-04
微信小程序下拉加載和上拉刷新兩種實(shí)現(xiàn)方法詳解
這篇文章主要介紹了微信小程序下拉加載和上拉刷新兩種實(shí)現(xiàn)方法詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-09-09
微信小程序?qū)崿F(xiàn)簡(jiǎn)單計(jì)算器
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)懞?jiǎn)單計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-04-04
javascript Three.js創(chuàng)建文字初體驗(yàn)
這篇文章主要為大家介紹了Three.js創(chuàng)建文字初體驗(yàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2021-11-11
window.name代替cookie的實(shí)現(xiàn)代碼
window.name代替cookie的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2010-11-11

