Vue實(shí)現(xiàn)Tab選項(xiàng)卡切換
本文實(shí)例為大家分享了Vue實(shí)現(xiàn)Tab選項(xiàng)卡切換的具體代碼,供大家參考,具體內(nèi)容如下
點(diǎn)擊不同的標(biāo)題顯示出相應(yīng)的圖片
代碼如下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="js/vue.js" type="text/javascript"></script> </head> <style> *{ margin: 0px; padding: 0px; } #tab{ width:420px; margin: 20px auto; position: relative; } #tab ul li{ width: 100px; height: 30px; border: 1px solid #6699CC; float: left; list-style: none; text-align: center; line-height: 30px; } #tab ul li:first-child{ border-right: none; /* border-radius: 10px 0px 0px 0px; */ } #tab ul li:last-child{ border-left: none; /* border-radius: 0px 10px 0px 0px; */ } #tab ul .active{ background-color:orange; color:white; } #tab div{ width: 415px; position: absolute; top: 32px; display: none; } #tab div img{ width: 350px; /* border-radius:0px 0px 10px 10px; */ } #tab div.current{ display: block; } </style> <body> <div id="tab"> <ul> <li v-on:mouseover="change(index)" :class="[currentindex==index?'active':'']":key="item.id"v-for="(item,index) in list">{{item.text}}</li> </ul> <div :class="[currentindex==index?'current':'']" v-for="(item,index) in list"> <img :key="item.id" v-bind:src="item.imgsrc"/> </div> </div> </body> <script type="text/javascript"> var vm = new Vue({ el:'#tab', data:{ currentindex:'0',//當(dāng)前選項(xiàng)卡的索引 list:[{ id:'1', text:'apple', imgsrc:'imgs/1.jpg' },{ id:'2', text:'orange', imgsrc:'imgs/2.jpg' },{ id:'3', text:'lemon', imgsrc:'imgs/3.jpg' }] }, methods:{ change:function(index){ this.currentindex=index; } } }); </script> </html>
效果圖
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue.js實(shí)現(xiàn)選項(xiàng)卡切換
- vue選項(xiàng)卡切換登錄方式小案例
- Vue.js組件實(shí)現(xiàn)選項(xiàng)卡以及切換特效
- vue實(shí)現(xiàn)選項(xiàng)卡及選項(xiàng)卡切換效果
- Vue.js tab實(shí)現(xiàn)選項(xiàng)卡切換
- vue中用動(dòng)態(tài)組件實(shí)現(xiàn)選項(xiàng)卡切換效果
- vue動(dòng)態(tài)組件實(shí)現(xiàn)選項(xiàng)卡切換效果
- Vue.js組件tab實(shí)現(xiàn)選項(xiàng)卡切換
- Vue.js組件tabs實(shí)現(xiàn)選項(xiàng)卡切換效果
- Vue實(shí)現(xiàn)選項(xiàng)卡tab切換制作
相關(guān)文章
vue 動(dòng)態(tài)添加的路由頁(yè)面刷新時(shí)失效的原因及解決方案
這篇文章主要介紹了vue動(dòng)態(tài)添加的路由頁(yè)面刷新時(shí)失效的原因及解決方案,幫助大家更好的理解和學(xué)習(xí)使用vue,感興趣的朋友可以了解下2021-02-02vue.js中使用微信掃一掃解決invalid signature問(wèn)題(完美解決)
這篇文章主要介紹了vue.js中使用微信掃一掃解決invalid signature問(wèn)題(推薦),本文通過(guò)實(shí)例代碼給出解決方法,代碼簡(jiǎn)單易懂非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04vue2.0嵌套路由實(shí)現(xiàn)豆瓣電影分頁(yè)功能(附demo)
這篇文章主要介紹了vue2.0嵌套路由實(shí)現(xiàn)豆瓣電影分頁(yè)功能(附demo),這里整理了詳細(xì)的代碼,有需要的小伙伴可以參考下。2017-03-03Vue設(shè)置瀏覽器小圖標(biāo)(ICON)的詳細(xì)步驟
vue中網(wǎng)頁(yè)圖標(biāo)默認(rèn)使用的是vue自帶的一個(gè)icon的圖標(biāo),也是vue的logo,下面這篇文章主要給大家介紹了關(guān)于Vue設(shè)置瀏覽器小圖標(biāo)(ICON)的詳細(xì)步驟,需要的朋友可以參考下2023-01-01Vue+Jwt+SpringBoot+Ldap完成登錄認(rèn)證的示例代碼
本篇文章主要介紹了Vue+Jwt+SpringBoot+Ldap完成登錄認(rèn)證的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-05-05Vue動(dòng)態(tài)組件component的深度使用說(shuō)明
這篇文章主要介紹了Vue動(dòng)態(tài)組件component的深度使用說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04