本文實例為大家分享了vue插件tab選項卡的具體代碼,供大家參考,具體內(nèi)容如下
效果圖:

代碼如下:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> *{padding: 0;margin: 0} #app{ width: 500px;height: 300px;margin: 0 auto;background-color: #ddd; } .top{ height: 50px;line-height: 50px;width: 100%;background-color: #999; } .top ul li{display: inline-block;margin:0 10px;} .top ul li a{text-decoration: none;color: white;} .bottom{ } </style></head><body> <div id="app"> <div class="top"> <ul> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" @click='tabToggle(tab01Text);'>{{tab01Text}}</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" @click='tabToggle(tab02Text);'>{{tab02Text}}</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" @click='tabToggle(tab03Text);'>{{tab03Text}}</a></li> </ul> </div> <div class="bottom"> <component :is='currentView' keep-alive></component> </div> </div> <script type="text/javascript" src='vue.js'></script> <script> var tab01 = Vue.extend({ template:'<p>This is tab01</p>' }) var tab02 = Vue.extend({ template:'<p>This is tab02</p>' }) var tab03 = Vue.extend({ template:'<p>This is tab03</p>' }) var app = new Vue({ el:'#app', data:{ tab01Text:'tab01', tab02Text:'tab02', tab03Text:'tab03', currentView:'tab01' }, components:{ tab01:tab01, tab02:tab02, tab03:tab03 }, methods:{ tabToggle:function(tabText){ this.currentView=tabText } } }) </script></body></html>本文已被整理到了《Vue.js前端組件學習教程》,歡迎大家學習閱讀。
關(guān)于vue.js組件的教程,請大家點擊專題vue.js組件學習教程進行學習。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點
疑難解答