vue實現tab切換功能精簡版
阿新 • • 發佈:2019-05-10
clas none nbsp port () lin line emp click
<template> <div> <p class="tabs" v-for="(list,index) in lists" :class="index == cur ? ‘red‘:‘‘" @click="cur = index"> {{list.title}} </p> <div class="content" v-for="(list,index) in lists" :style="{display: index==cur ? ‘block‘:‘none‘}"> {{list.name}} </div> </div> </template> <script> export default { data () { return { lists: [ { title: "切換1", name: "內容1111" }, { title: "切換2", name:"內容2222" } ], cur: 0 } } } </script> <style scoped> .tabs { display: inline-block; margin-left:10px; } .red { color: red; } .content { padding: 5px; } </style>
vue實現tab切換功能精簡版