Vue 实现双层Tab切换(最大的坑就是img动态设置src引入问题)本地图片要放static文件夹下

本文主要是介绍Vue 实现双层Tab切换(最大的坑就是img动态设置src引入问题)本地图片要放static文件夹下,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

<template><div id="app"><div class="main"><h1>Vue实现双层Tab切换</h1><div class="main_header"><button :class="{btn:true, slect_btn:select==obj.name}"  v-for="(obj) in datascore" @click="change(obj)">{{obj.name}}</button> </div><div class="main_content"><div class="one" v-for="(obj,index) in  datascore" v-if="obj.name==select"><button :class="{btn:true,slect_btn:children_select==obj1.c_name}"   v-for="(obj1) in obj.content" @click="children_change(obj1.c_name)">{{obj1.c_name}}</button> <div class="one_content" v-if="children_select==obj1.c_name"  v-for="(obj1) in obj.content" ><div class="one_content_one" v-for="(obj2) in obj1.children"><img style="width:164px;height: 190px;" :src="obj2.img" /><br/>{{obj2.d_name}}</div></div></div></div></div></div></div>
</template>
<script>
import daiyue_1 from "@/../static/img/daiyue.jpg";
import daiyue_2 from "@/../static/img/daiyue2.jpg";
import daiyue_3 from "@/../static/img/daiyue3.jpg";
import daiyue_4 from "@/../static/img/daiyue4.jpg";
import daiyue_5 from "@/../static/img/daiyue5.jpg";
import liuneng1 from "@/../static/img/liuneng.jpg";
import liuneng2 from "@/../static/img/liuneng2.jpg";
import liuneng3 from "@/../static/img/liuneng3.jpg";
import angle1 from "@/../static/img/angle1.jpg";
import angle2 from "@/../static/img/angle2.jpg";
import angle3 from "@/../static/img/angle3.jpg";
import chiji1 from "@/../static/img/chiji1.jpg";
import chiji2 from "@/../static/img/chiji2.jpg";
import chiji3 from "@/../static/img/chiji3.jpg";
import jiashiqi1 from "@/../static/img/jiashiqi1.jpg";
import jiashiqi2 from "@/../static/img/jiashiqi2.jpg";
export default {name: 'app',data () {return {datascore:[{name:"明星",content:[ {c_name:"戴玥",children:[{d_name:"戴玥",img:daiyue_1},{d_name:"戴玥",img:daiyue_2},{d_name:"戴玥",img:daiyue_3},{d_name:"戴玥",img:daiyue_4},]},{c_name:"刘能",children:[{d_name:"刘能",img:liuneng1},{d_name:"刘能",img:liuneng2},{d_name:"刘能",img:liuneng3},]},{c_name:"angleBaby",children:[{d_name:"angleBaby",img:angle1},{d_name:"angleBaby",img:angle2},{d_name:"angleBaby",img:angle3},]}],},{name:"游戏",  content:[{c_name:"吃鸡",children:[{d_name:"吃鸡",img:chiji1},{d_name:"吃鸡",img:chiji2},{d_name:"吃鸡",img:chiji3},]},{c_name:"加湿器",children:[{d_name:"加湿器",img:jiashiqi1},{d_name:"加湿器",img:jiashiqi2},]},],}],select:'明星',children_select:"戴玥",};},components: {},methods: {change(obj){this.select=obj.namethis.children_select=obj.content[0].c_name;},children_change(flag){this.children_select=flag;},},}
</script><style>
.one_content{width: 100%;height: 530px;background-color: white;
}
.main_content{width: 100%;height: 565px;background-color: aqua;
}
.slect_btn{background-color:white !important;
}
.main_header{background-color: #CCC;
}
.one,{width:800px;height:565px;
}span{display: inline-block;width: 100px;height: 60px;}.btn{text-overflow: ellipsis;overflow: hidden;white-space: nowrap;background-color:rgb(204, 204, 204);border-color: rgba(0, 0, 0, 0.3);box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.95);color: #000;border: 1px solid #CCC;border-radius: 5px;padding: 6px;width: 80px;text-align: center;cursor: pointer;}
#app {font-family: 'Avenir', Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;margin-top: 60px;
}
.main{width: 800px;height: 600px;margin: 0px auto;border:1px solid rgb(204, 204, 204);
}
.one_content_one{width: 200px;height: 200px;display: inline-block;vertical-align: top;
}
</style>

 

这篇关于Vue 实现双层Tab切换(最大的坑就是img动态设置src引入问题)本地图片要放static文件夹下的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/732803

相关文章

CentOS和Ubuntu系统使用shell脚本创建用户和设置密码

《CentOS和Ubuntu系统使用shell脚本创建用户和设置密码》在Linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设置密码,本文写了一个shell... 在linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

解决IDEA报错:编码GBK的不可映射字符问题

《解决IDEA报错:编码GBK的不可映射字符问题》:本文主要介绍解决IDEA报错:编码GBK的不可映射字符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录IDEA报错:编码GBK的不可映射字符终端软件问题描述原因分析解决方案方法1:将命令改为方法2:右下jav

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

Maven中引入 springboot 相关依赖的方式(最新推荐)

《Maven中引入springboot相关依赖的方式(最新推荐)》:本文主要介绍Maven中引入springboot相关依赖的方式(最新推荐),本文给大家介绍的非常详细,对大家的学习或工作具有... 目录Maven中引入 springboot 相关依赖的方式1. 不使用版本管理(不推荐)2、使用版本管理(推

MyBatis模糊查询报错:ParserException: not supported.pos 问题解决

《MyBatis模糊查询报错:ParserException:notsupported.pos问题解决》本文主要介绍了MyBatis模糊查询报错:ParserException:notsuppo... 目录问题描述问题根源错误SQL解析逻辑深层原因分析三种解决方案方案一:使用CONCAT函数(推荐)方案二:

在 Spring Boot 中实现异常处理最佳实践

《在SpringBoot中实现异常处理最佳实践》本文介绍如何在SpringBoot中实现异常处理,涵盖核心概念、实现方法、与先前查询的集成、性能分析、常见问题和最佳实践,感兴趣的朋友一起看看吧... 目录一、Spring Boot 异常处理的背景与核心概念1.1 为什么需要异常处理?1.2 Spring B

Python位移操作和位运算的实现示例

《Python位移操作和位运算的实现示例》本文主要介绍了Python位移操作和位运算的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 位移操作1.1 左移操作 (<<)1.2 右移操作 (>>)注意事项:2. 位运算2.1

如何在 Spring Boot 中实现 FreeMarker 模板

《如何在SpringBoot中实现FreeMarker模板》FreeMarker是一种功能强大、轻量级的模板引擎,用于在Java应用中生成动态文本输出(如HTML、XML、邮件内容等),本文... 目录什么是 FreeMarker 模板?在 Spring Boot 中实现 FreeMarker 模板1. 环