這篇文章給大家分享的是有關(guān)vue和bootstrap的示例分析的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
vue和angular非常像都是MVVM。道理都是想通的,就是語法的差異
我覺得vue和angular區(qū)別:
1.vue更輕,更便捷,適用于移動開發(fā)
2.vue更簡單。。
angular和vue指令的差別大致就是 ng-xxx和v-xxx。
vue是用過new Vue創(chuàng)建實(shí)例,然后在屬性data綁定數(shù)據(jù),在屬性methods里添加方法。
vue的循環(huán)遍歷是 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>暫無數(shù)據(jù)</p> </td> </tr> </table> </div> </body> </html>
效果:
感謝各位的閱讀!關(guān)于“vue和bootstrap的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站www.rwnh.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享標(biāo)題:vue和bootstrap的示例分析-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://www.rwnh.cn/article46/dopoeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、虛擬主機(jī)、網(wǎng)站營銷、面包屑導(dǎo)航、響應(yīng)式網(wǎng)站、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容