如何利用vue做一个选项卡切换效果,下面web建站小编给大家简单介绍一下具体实现代码!
具体实现代码如下:
<template> <div> <ul> <li v-for="(item, index) in tabs" :key="index" :class="{ active: item.active }" @click="selectedTab = item"> {{ item.name }} </li> </ul> <div v-for="(item, index) in tabs" :key="index" v-if="item.active"> {{ item.content }} </div> </div> </template> <script> export default { data() { return { tabs: [ { name: 'tab1', content: '内容1', active: true }, //默认 { name: 'tab2', content: '内容2', active: false }, { name: 'tab3', content: '内容3', active: false } ] } }, computed: { selectedTab() { return this.tabs.find(item => item.active); } }, methods: { selectTab(item) { this.tabs.forEach(item => item.active = false); item.active = true; } } } </script>
Motion for Vue:一个轻量级且功能强大的Vue3动画库
el-table利用:row-style="rowClass"设置指定行变色
一款免费开源效果酷炫的 Vue / React 大屏数据展示组件库——DataV
上面是“如何利用vue实现一个选项卡切换效果”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4021.html
workflows工作流
一只蚂蚁在花丛中找食物ComfyUI工作流
一个白色的咖啡杯,蒸汽从杯子里冒出来
一个红头发明亮眼睛的漂亮女人
森林里一只邪恶的树妖ComfyUI工作流
文生图工作流:图片合并comfyui工作流
乡村枯树黄花comfyui工作流
一位身穿金色铠甲的美丽女子守卫在寺庙外
一张精心制作的熊岛复古地图ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!