vue bootstrap小例子一枚,vuebootstrap一枚

來源:互聯網
上載者:User

vue bootstrap小例子一枚,vuebootstrap一枚

vue和angular非常像都是MVVM。道理都是想通的,就是文法的差異 

我覺得vue和angular區別: 

1.vue更輕,更便捷,適用於移動開發 

2.vue更簡單。。 

angular和vue指令的差別大致就是 ng-xxx和v-xxx。 
vue是用過new Vue建立執行個體,然後在屬性data綁定資料,在屬性methods裡添加方法。 
vue的迴圈遍曆是 v-for=“” ,事件是 v-on:clicl =“”;

直接上代碼。

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="bootstrap.css" rel="external nofollow" > <style>  tr{   vertical-align: inherit;  } </style> <script src="jquery.js"></script> <script src="bootstrap.js"></script> <script src="node_modules/vue/dist/vue.js"></script> <script>  window.onload= function(){   var vm = new Vue({    el:'.container',    data:{     myData:[],     username:'',     age:''    },    methods:{     add:function(){      this.myData.push({       name:this.username,       age:this.age      });      this.username="";      this.age="";     },     reset:function(){      this.username="";      this.age="";     },     del:function(index){      this.myData.splice(index,1)     },     delAll:function(){      this.myData=[];     }    }   })  } </script></head><body> <div class="container">  <form role="form">   <div class="form-group">    <label for="username">使用者名稱:</label>    <input placeholder="輸入使用者名稱" type="text"      v-model="username"      id="username" class="form-control">   </div>   <div class="form-group">    <label for="age">年齡:</label>    <input placeholder="輸入年齡" type="text"      v-model="age"      id="age" class="form-control">   </div>   <div class="form-group">    <input type="button" class="btn btn-info" v-on:click="add()" value="添加">    <input type="button" class="btn btn-info" v-on:click="reset()" value="重設">   </div>  </form>  <hr>  <table class="table table-bordered table-hover">   <caption>使用者資訊表</caption>   <tr class="text-danger">    <td class="text-center">序號</td>    <td class="text-center">名字</td>    <td class="text-center">年齡</td>    <td class="text-center">操作</td>   </tr>   <tr v-for="(item,index) in myData">    <td class="text-center">{{index+1}}</td>    <td class="text-center">{{item.name}}</td>    <td class="text-center">{{item.age}}</td>    <td class="text-center">     <button class="btn btn-danger btn-sm"      v-on:click="del(index)"      data-toggle="dialog" data-target="#layer"     >刪除</button>    </td>   </tr>   <tr v-show="myData.length!=0">    <td colspan="4" class="text-right">     <button v-on:click="delAll()" class="btn btn-danger btn-sm">刪除全部</button>    </td>   </tr>   <tr v-show="myData.length==0">    <td colspan="4" class="text-center">     <p>暫無資料</p>    </td>   </tr>  </table> </div></body></html>

效果:

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.