首页 技术 正文
技术 2022年11月14日
0 收藏 322 点赞 4,305 浏览 2337 个字

vue实现筛选功能,文字选中变色

vue实现筛选功能,文字选中变色

 <template>
<Poptip trigger="hover" title="Title" content="content">
<i-button>Hover</i-button>
</Poptip>
<Poptip trigger="hover" title="Title" content="content">
<i-button>Hover</i-button>
</Poptip>
<Poptip trigger="hover" title="Title" content="content">
<i-button>Hover</i-button>
</Poptip>
<Poptip trigger="hover" title="Title" content="content">
<i-button>Hover</i-button>
</Poptip>
<Poptip title="" content="content">
<i-button>筛选</i-button>
<div class="api" slot="content">
<Tabs :animated="false" v-model="currentTab" @on-click="currentTabChanged">
<tab-pane label="学院" name="xy">
<i-row v-for="item in xyList" @click='showZy(item)'>
<i-col span="12" class="xy" :class="{'selectedColor':flag1==item.id}">
{{item.label}}
</i-col>
</i-row>
</tab-pane>
<tab-pane label="专业" name="zy" v-if="show2">
<i-row v-for="item in xyList.zy" @click="showList(item)">
<i-col span="12" class="xy" :class="{'selectedColor':flag2==item.id}">
{{item.label}}
</i-col>
</i-row>
</tab-pane>
</Tabs>
</div>
</Poptip>
</template>
<script>
export default {
data() {
return {
currentTab: 'xy',
show2: false,
flag1: -1,
flag2: -1,
xyList: [{
value: 'renwen',
id: 1,
label: '马克思主义学院',
zy: [{
value: 'xinxi',
id: 1,
label: '马克思'
},
{
value: 'gongcheng',
id: 2,
label: '马克思'
},
{
value: 'tongxin',
id: 3,
label: '马克思'
}
]
},
{
value: 'dili',
id: 2,
label: '地理信息科学技术学院',
zy: [{
value: 'xinxi',
id: 1,
label: '地理'
},
{
value: 'gongcheng',
id: 2,
label: '地理'
},
{
value: 'tongxin',
id: 3,
label: '地理'
}
]
},
{
value: 'sheke',
id: 3,
label: '社科',
zy: [{
value: 'xinxi',
id: 1,
label: '社科'
},
{
value: 'gongcheng',
id: 2,
label: '社科'
},
{
value: 'tongxin',
id: 3,
label: '社科'
}
]
},
{
value: 'renwen',
id: 4,
label: '人文',
zy: [{
value: 'xinxi',
id: 1,
label: '人文'
},
{
value: 'gongcheng',
id: 2,
label: '人文'
},
{
value: 'tongxin',
id: 3,
label: '人文'
}
]
},
{
value: 'dili',
id: 5,
label: '地理',
zy: [{
value: 'xinxi',
id: 1,
label: '地理'
},
{
value: 'gongcheng',
id: 2,
label: '地理'
},
{
value: 'tongxin',
id: 3,
label: '地理'
}
]
},
{
value: 'sheke',
id: 6,
label: '社科',
zy: [{
value: 'xinxi',
id: 1,
label: '社科'
},
{
value: 'gongcheng',
id: 2,
label: '社科'
},
{
value: 'tongxin',
id: 3,
label: '社科'
}
]
}
]
}
},
methods: {
currentTabChanged(name) {
if(this.currentTab == 'xy'){
// this.show2 = false
}
},
showZy(item) {
if (item.label) {
this.flag1 = item.id
this.xyList.zy = item.zy
this.show2 = true
this.currentTab = 'zy'
// console.log(this.xyList.zy)
}
},
showList(item) {
if (item.label) {
this.flag2 = item.id
// console.log(item.label)
}
}
}
}
</script> <style>
span {
padding: 10px;
cursor: pointer;
} .xy {
cursor: pointer;
padding: 5px;
box-sizing: border-box;
} .selectedColor {
color: #2d8cf0;
}
</style>

复制以上代码到 run ivew 网站预览效果

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,031
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,860