1. 程式人生 > 其它 >vue實現選項卡

vue實現選項卡

技術標籤:vue

選項卡

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"
>
</script> <style> #app>div{ width: 200px; height: 300px; border: 1px solid red; } .active{ background-color: blue; } </style> </head> <body> <div id="app"> <button
v-for="(item,index) in list" @click="num=index" :class="{active:index===num}">
{{item}}</button> <div class="wq" v-for="(item,index) in list1" v-show="index===num?true:false">{{item}}</div> </div> <script
>
new Vue({ el:"#app", data:{ num:0, list:['1','2','3'], list1:['111111','2222222','3333333'] } }) </script> </body> </html>

效果圖
在這裡插入圖片描述