91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

利用vue.js把靜態json綁定bootstrap的table方法

發布時間:2020-10-01 00:28:10 來源:腳本之家 閱讀:375 作者:stevennest 欄目:web開發

直接上代碼

嘻嘻,發現bootstrap+vue.js拿來做原型效率挺高,以后就這樣做原型

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.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">
   <h2>Vue demo</h2>
   <div id="app">
    <table class="table">
     <tr>
      <td><input type="checkbox"></td>
      <td>id</td>
      <td>書名</td>
      <td>作者</td>
      <td>價格</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">&times;</span><span class="sr-only">Close</span></button>
        <h5 class="modal-title" id="myModalLabel">Modal title</h5>
       </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: '紅樓夢',
    price: 32.0
   }, {
    id: '2',
    author: '施耐庵',
    name: '水滸傳',
    price: 30.0
   }, {
    id: '3',
    author: '羅貫中',
    name: '三國演義',
    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把靜態json綁定bootstrap的table方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

梁平县| 繁峙县| 漳州市| 芦山县| 正安县| 临沭县| 柳林县| 延庆县| 谢通门县| 临桂县| 巴彦县| 吴旗县| 乌拉特中旗| 随州市| 镇沅| 融水| 二连浩特市| 门源| 富阳市| 浪卡子县| 神农架林区| 四平市| 磴口县| 碌曲县| 洛南县| 祁阳县| 北安市| 岚皋县| 寻乌县| 三河市| 丁青县| 平定县| 册亨县| 罗田县| 绥滨县| 应用必备| 潢川县| 正蓝旗| 南岸区| 班戈县| 南投市|