日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue实现点击标题,显示隐藏兄弟元素(类似电脑打印设备显示打印设备)

發布時間:2023/12/29 vue 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue实现点击标题,显示隐藏兄弟元素(类似电脑打印设备显示打印设备) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本代碼實現的功能:可動態添加里面的任何一級別的代碼(不固定級別)
html代碼:

<div class="hx-bigListOne"><div class="hx-bigLiOne" v-for="item in items" :key="item.id"><h5 class="hx-OneTit" @click="toggle(item)">{{item.title}}</h5><div v-show="item.show" class="hx-bigListTwo"><div class="hx-bigLiTwo" v-for="li in item.data" :key="li.id"><div class="hx-smaD"><div style="width:80px;height:80px"></div><span style="font-size:12px">{{li.text}}</span></div></div></div></div></div> </div>

js代碼:

data: function() {
return {
items: [
{
title: “劃傷類型”,
data: [
{ text: “this is a text” },
{ text: “this is a text” },
{ text: “this is a text” }
],
show: false
},
{
title: “磕傷類型”,
data: [
{ text: “this is a text” },
{ text: “this is a text” },
{ text: “this is a text” }
],
show: false
},
{
title: “其他類型”,
data: [
{ text: “this is a text” },
{ text: “this is a text” },
{ text: “this is a text” }
],
show: false
}
],
}}
methods: {
toggle(item) {
if(item.data.length!=0){
item.show = !item.show;
}else{
item.show = item.show;
}
},
}

css代碼:

.hx-bigListOne {
margin-left: 30px;
}
.hx-bigLiOne {
margin: 0 30px 10px 0;
height: auto;
}
.hx-OneTit {
width: 150px;
height: 30px;
font-size: 20px;
line-height: 30px;
}
.hx-bigListTwo {
height: 110px;
}
.hx-bigLiTwo {
float: left;
}
.hx-smaD {
width: 110px;
margin: 10px 15px;
}

實現的效果:

總結

以上是生活随笔為你收集整理的vue实现点击标题,显示隐藏兄弟元素(类似电脑打印设备显示打印设备)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。