国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

利用vue.js把靜態(tài)json綁定bootstrap的table方法

2019-11-19 13:07:28
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

直接上代碼

嘻嘻,發(fā)現(xiàn)bootstrap+vue.js拿來(lái)做原型效率挺高,以后就這樣做原型

<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" type="text/css"  rel="external nofollow" > <script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.js"></script> <script src="https://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="https://unpkg.com/vue/dist/vue.js"></script></head></head><body> <div class="container">  <!-- start list -->  <div class="col-md-6 col-md-offset-3">   <h1>Vue demo</h1>   <div id="app">    <table class="table">     <tr>      <td><input type="checkbox"></td>      <td>id</td>      <td>書(shū)名</td>      <td>作者</td>      <td>價(jià)格</td>     </tr>     <tr v-for="book in books ">      <td>       <label>        <input type="checkbox" v-bind:value="book.id" v-model="checkedNames">       </label>      </td>      <td>{{book.id}}</td>      <td>{{book.name}}</td>      <td>{{book.author}}</td>      <td>{{book.price}}</td>     </tr>     <tr>      <td colspan="5">       <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">add</button>       <button type="button" class="btn btn-primary" v-on:click="delItems">delete</button>      </td>     </tr>    </table>    <p>Checked names: {{ checkedNames }}</p>    <!-- start modal -->    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">     <div class="modal-dialog">      <div class="modal-content">       <div class="modal-header">        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>        <h4 class="modal-title" id="myModalLabel">Modal title</h4>       </div>       <div class="modal-body">        <input class="form-control" placeholder="input id" v-model="book.id">        <input class="form-control" placeholder="input author" v-model="book.author">        <input class="form-control" placeholder="input name" v-model="book.name">        <input class="form-control" placeholder="input price" v-model="book.price">       </div>       <div class="modal-footer">        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>        <button type="button" class="btn btn-primary" data-dismiss="modal" v-on:click="addItem">Save changes</button>       </div>      </div>     </div>    </div>    <!-- end modal -->   </div>  </div>  <!-- end list --> </div></body><script> new Vue({  el: '#app',  data: {   book: {    id: '0',    author: '',    name: '',    price: ''   },   checkedNames: [],   books: [{    id: '1',    author: '曹雪芹',    name: '紅樓夢(mèng)',    price: 32.0   }, {    id: '2',    author: '施耐庵',    name: '水滸傳',    price: 30.0   }, {    id: '3',    author: '羅貫中',    name: '三國(guó)演義',    price: 24.0   }, {    id: '4',    author: '吳承恩',    name: '西游記',    price: 20.0   }]  },  methods:{   delItems : function() {    for (var i = 0 ; i < this.checkedNames.length ; i++) {     for(var j = 0 ; j < this.books.length ; j++){      var cur_book = this.books[j];      if(cur_book.id == this.checkedNames[i]){       this.books.splice(j,1);      }     }    }    this.checkedNames = [];   },   addItem : function(){    this.books.push(this.book);   }  } })</script></html>

以上這篇利用vue.js把靜態(tài)json綁定bootstrap的table方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 敦化市| 泸水县| 渝中区| 马尔康县| 富民县| 福建省| 江西省| 涿州市| 三河市| 裕民县| 迁西县| 岳池县| 沂水县| 略阳县| 安庆市| 天峻县| 额济纳旗| 柳州市| 铁力市| 佛山市| 上蔡县| 仪陇县| 芜湖市| 盘锦市| 白银市| 麻江县| 章丘市| 密云县| 申扎县| 乡城县| 交口县| 临湘市| 巴彦淖尔市| 武夷山市| 于都县| 集安市| SHOW| 万年县| 百色市| 胶南市| 科技|