最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue與bootstrap實(shí)現(xiàn)簡單用戶信息添加刪除功能

 更新時(shí)間:2019年02月15日 13:28:05   作者:qq_39201210  
這篇文章主要為大家詳細(xì)介紹了vue與bootstrap實(shí)現(xiàn)簡單用戶信息添加刪除功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue與bootstrap實(shí)現(xiàn)用戶信息添加刪除操作的具體代碼,供大家參考,具體內(nèi)容如下

小記:

1.v-model=""    用于input表單雙向數(shù)據(jù)綁定  邏輯層跟渲染層雙向綁定

2.v-on:click='add()'     click方法綁定 

3.v-for='(item,index) in myData'   遍歷數(shù)組  {{index}}      {{item.name}}      {{item.age}}   適用于vue版本2.0  

4.v-for='(item,index,key) in myData'   遍歷json  {{index}}      {{item}}      {{key}}   適用于vue版本2.0

5.v-on:click="currentUser=index"    直接綁定點(diǎn)擊事件改變邏輯層的數(shù)據(jù)  currentUser這里是邏輯層的數(shù)據(jù) 

6.v-show="myData.length!=0"   v-show根據(jù)后面的布爾值覺得顯示還是隱藏  可直接用邏輯層的數(shù)據(jù)進(jìn)行判斷

7.<div class="modal" role='dialog' id="layer"> modal  dialog為遮罩框 id用來聯(lián)系觸發(fā)元素

8. data-toggle='modal'   交替顯示隱藏遮罩框  data-target='#layer'    確定目標(biāo)模態(tài)框

9. data-dismiss='modal'  點(diǎn)擊后消失目標(biāo)元素

效果圖:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0" >
 <title>Document</title>
 <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"  rel="external nofollow" >
 <script src='../jquery-3.2.1.min.js'></script>
 <script src='bootstrap.js'></script>
 <script src='vue.js'></script>
 <style>
 table td {vertical-align: middle !important;}
 </style>
</head>
<body>
<div class="container">
 
 <form action="" role='form' class="">
 <div class="form-group">
 <label for="username" class="">用戶名:</label>
 <input type="text" id="username" class="form-control" v-model="username" placeholder="請輸入用戶名">
 </div>
 <div class="form-group">
 <label for="age">年 齡:</label>
 <input type="text" id="age" class="form-control" v-model="age" placeholder="請輸入年齡">
 </div>
 <div class="form-group">
 <input type="button" value="添加" class="btn btn-primary" v-on:click='add()'>
 <input type="reset" value="重置" class="btn btn-warning">
 </div>
 </form>
 <table class="table table-bordered table-hover">
 <caption class="h4 text-info text-center">用戶信息表</caption>
 <tr class="text-danger">
 <th class="text-center">序號</th>
 <th class="text-center">姓名</th>
 <th class="text-center">年齡</th>
 <th class="text-center">操作</th>
 </tr>
 <tr class="text-center" v-for='(item,index) in myData'>
 <td>{{index}}</td>
 <td>{{item.name}}</td>
 <td>{{item.age}}</td>
 <td>
 <button class="btn btn-danger btn-xs" data-toggle='modal' data-target='#layer' v-on:click="currentUser=index">刪除</button>
 </td>
 </tr>
 <tr v-show="myData.length!=0">
 <td colspan="4" class="text-right">
 <button class="btn btn-danger btn-xs" v-on:click='currentUser="all"' data-toggle='modal' data-target="#layer">全部刪除</button>
 </td>
 </tr>
 <tr v-show="myData.length==0">
 <td colspan="4" class="text-center">
 <p class="text-muted">暫無數(shù)據(jù)...</p>
 </td>
 </tr>
 </table>
 <div class="modal fade bs-example-modal-sm" role='dialog' id="layer">
 <div class="modal-dialog">
 <div class="modal-content">
 <div class="modal-header">
  <button class="close" data-dismiss='modal'>
  <span>&times;</span>
  </button>
  <h4 class="modal-title">確認(rèn)刪除嗎?</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" data-dismiss='modal' v-on:click="deleteuser()">確認(rèn)</button>
 </div>
 </div>
 </div>
 </div>
 
 
</div>
</body>
</html>
<script>
 var c = new Vue({
 el:'.container',
 data:{
 myData:[
 {name:"張三",age:20},
 {name:"李四",age:20},
 {name:"王五",age:20},
 ],
 username:"",
 age:"",
 currentUser :-100,
 },
 methods : {
 deleteuser :function(){
 if (this.currentUser == 'all') {
  this.myData = [];
 }else{
  this.myData.splice(this.currentUser,1);
 }
 },
 add : function(){
 if (this.username!=""&&this.age!=0) {
  this.myData.push({
  name:this.username,
  age:this.age
  })
 }
 },
 }
 })
</script>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue-cli2與vue-cli3在一臺電腦共存的實(shí)現(xiàn)方法

    vue-cli2與vue-cli3在一臺電腦共存的實(shí)現(xiàn)方法

    這篇文章主要介紹了vue-cli2與vue-cli3在一臺電腦共存的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • Vue3實(shí)現(xiàn)刷新頁面局部內(nèi)容的示例代碼

    Vue3實(shí)現(xiàn)刷新頁面局部內(nèi)容的示例代碼

    本文主要介紹了Vue3實(shí)現(xiàn)刷新頁面局部內(nèi)容的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • 通過實(shí)例解析vuejs如何實(shí)現(xiàn)調(diào)試代碼

    通過實(shí)例解析vuejs如何實(shí)現(xiàn)調(diào)試代碼

    這篇文章主要介紹了通過實(shí)例解析vuejs如何實(shí)現(xiàn)調(diào)試代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-07-07
  • vue3動(dòng)態(tài)路由解決刷新頁面空白或跳轉(zhuǎn)404問題

    vue3動(dòng)態(tài)路由解決刷新頁面空白或跳轉(zhuǎn)404問題

    這篇文章主要為大家詳細(xì)介紹了vue3如何通過動(dòng)態(tài)路由解決刷新頁面空白或跳轉(zhuǎn)404問題,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2025-01-01
  • Vue使用swiper問題(5.2.0版本,避免踩坑)

    Vue使用swiper問題(5.2.0版本,避免踩坑)

    這篇文章主要介紹了Vue使用swiper問題(5.2.0版本,避免踩坑),具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • vue3實(shí)現(xiàn)點(diǎn)擊空白區(qū)域隱藏div

    vue3實(shí)現(xiàn)點(diǎn)擊空白區(qū)域隱藏div

    這篇文章主要介紹了vue3實(shí)現(xiàn)點(diǎn)擊空白區(qū)域隱藏div方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • 用Vue封裝導(dǎo)航欄組件

    用Vue封裝導(dǎo)航欄組件

    這篇文章主要為大家詳細(xì)介紹了用Vue封裝導(dǎo)航欄組件的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Vue自定義指令實(shí)現(xiàn)點(diǎn)擊右鍵彈出菜單示例詳解

    Vue自定義指令實(shí)現(xiàn)點(diǎn)擊右鍵彈出菜單示例詳解

    這篇文章主要為大家介紹了Vue自定義指令實(shí)現(xiàn)點(diǎn)擊右鍵彈出菜單示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • Vue中計(jì)算屬性未生效:原因、排查與解決過程

    Vue中計(jì)算屬性未生效:原因、排查與解決過程

    本文將深入探討計(jì)算屬性未生效的常見原因,并提供排查和解決方法,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • 前端vuex中dispatch的使用方法總結(jié)

    前端vuex中dispatch的使用方法總結(jié)

    這篇文章主要給大家介紹了關(guān)于前端vuex中dispatch使用方法的相關(guān)資料,vuex的dispatch方法用于觸發(fā)一個(gè)action,以便更新state,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-04-04

最新評論

平安县| 平利县| 军事| 房山区| 布拖县| 砚山县| 习水县| 富裕县| 高阳县| 阜南县| 盐边县| 东莞市| 岗巴县| 佳木斯市| 宝丰县| 连江县| 修武县| 洞头县| 无极县| 房产| 彝良县| 陵水| 通渭县| 邻水| 潞城市| 手机| 光泽县| 永宁县| 梓潼县| 南平市| 当雄县| 名山县| 晋城| 竹山县| 南雄市| 南川市| 鄂温| 鄢陵县| 九龙县| 元氏县| 富阳市|