欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用Bootstrap和Vue實(shí)現(xiàn)用戶信息的編輯刪除功能

 更新時(shí)間:2017年10月25日 16:09:59   作者:kodeliang  
這篇文章主要介紹了使用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">暫無(wú)信息...</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>&times;</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)編輯刪除的功能,因此密碼就直接顯示在表格中,沒(méi)有進(jìn)行加密顯示

整體布局界面


這是整體布局界面

用戶信息編輯后添加

用戶信息編輯后添加

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

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

總結(jié)

以上所述是小編給大家介紹的使用Bootstrap和Vue實(shí)現(xiàn)用戶信息的編輯刪除功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論