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

摘要:
123Hover456Hover78˂Popti

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

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

1 <template>
2     <Poptip trigger="hover"title="Title"content="content">
3         <i-button>Hover</i-button>
4     </Poptip>
5     <Poptip trigger="hover"title="Title"content="content">
6         <i-button>Hover</i-button>
7     </Poptip>
8     <Poptip trigger="hover"title="Title"content="content">
9         <i-button>Hover</i-button>
10     </Poptip>
11     <Poptip trigger="hover"title="Title"content="content">
12         <i-button>Hover</i-button>
13     </Poptip>
14     <Poptip title=""content="content">
15         <i-button>筛选</i-button>
16         <div class="api"slot="content">
17             <Tabs :animated="false"v-model="currentTab"@on-click="currentTabChanged">
18                 <tab-pane label="学院"name="xy">
19                     <i-row v-for="item in xyList"@click='showZy(item)'>
20                         <i-col span="12"class="xy":class="{'selectedColor':flag1==item.id}">
21 {{item.label}}
22                         </i-col>
23                     </i-row>
24                 </tab-pane>
25                 <tab-pane label="专业"name="zy"v-if="show2">
26                     <i-row v-for="item in xyList.zy"@click="showList(item)">
27                         <i-col span="12"class="xy":class="{'selectedColor':flag2==item.id}">
28 {{item.label}}
29                         </i-col>
30                     </i-row>
31                 </tab-pane>
32             </Tabs>
33         </div>
34     </Poptip>
35 </template>
36 <script>
37 export default{
38 data() {
39             return{
40 currentTab: 'xy',
41 show2: false,
42 flag1: -1,
43 flag2: -1,
44 xyList: [{
45 value: 'renwen',
46 id: 1,
47 label: '马克思主义学院',
48 zy: [{
49 value: 'xinxi',
50 id: 1,
51 label: '马克思'
52 },
53 {
54 value: 'gongcheng',
55 id: 2,
56 label: '马克思'
57 },
58 {
59 value: 'tongxin',
60 id: 3,
61 label: '马克思'
62 }
63 ]
64 },
65 {
66 value: 'dili',
67 id: 2,
68 label: '地理信息科学技术学院',
69 zy: [{
70 value: 'xinxi',
71 id: 1,
72 label: '地理'
73 },
74 {
75 value: 'gongcheng',
76 id: 2,
77 label: '地理'
78 },
79 {
80 value: 'tongxin',
81 id: 3,
82 label: '地理'
83 }
84 ]
85 },
86 {
87 value: 'sheke',
88 id: 3,
89 label: '社科',
90 zy: [{
91 value: 'xinxi',
92 id: 1,
93 label: '社科'
94 },
95 {
96 value: 'gongcheng',
97 id: 2,
98 label: '社科'
99 },
100 {
101 value: 'tongxin',
102 id: 3,
103 label: '社科'
104 }
105 ]
106 },
107 {
108 value: 'renwen',
109 id: 4,
110 label: '人文',
111 zy: [{
112 value: 'xinxi',
113 id: 1,
114 label: '人文'
115 },
116 {
117 value: 'gongcheng',
118 id: 2,
119 label: '人文'
120 },
121 {
122 value: 'tongxin',
123 id: 3,
124 label: '人文'
125 }
126 ]
127 },
128 {
129 value: 'dili',
130 id: 5,
131 label: '地理',
132 zy: [{
133 value: 'xinxi',
134 id: 1,
135 label: '地理'
136 },
137 {
138 value: 'gongcheng',
139 id: 2,
140 label: '地理'
141 },
142 {
143 value: 'tongxin',
144 id: 3,
145 label: '地理'
146 }
147 ]
148 },
149 {
150 value: 'sheke',
151 id: 6,
152 label: '社科',
153 zy: [{
154 value: 'xinxi',
155 id: 1,
156 label: '社科'
157 },
158 {
159 value: 'gongcheng',
160 id: 2,
161 label: '社科'
162 },
163 {
164 value: 'tongxin',
165 id: 3,
166 label: '社科'
167 }
168 ]
169 }
170 ]
171 }
172 },
173 methods: {
174 currentTabChanged(name) {
175                 if(this.currentTab == 'xy'){
176                     //this.show2 = false
177 }
178 },
179 showZy(item) {
180                 if(item.label) {
181                     this.flag1 =item.id
182                     this.xyList.zy =item.zy
183                     this.show2 = true
184                     this.currentTab = 'zy'
185                     //console.log(this.xyList.zy)
186 }
187 },
188 showList(item) {
189                 if(item.label) {
190                     this.flag2 =item.id
191                     //console.log(item.label)
192 }
193 }
194 }
195 }
196 </script>
197 
198 <style>
199 span {
200 padding:10px;
201 cursor:pointer;
202     }
203 
204 .xy {
205 cursor:pointer;
206 padding:5px;
207 box-sizing:border-box;
208     }
209 
210 .selectedColor {
211 color:#2d8cf0;
212     }
213 </style>

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

免责声明:文章转载自《vue实现筛选功能,文字选中变色》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇CL.exeCSDN账号被冻结了怎么办下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vue项目中 —— rem布局适配方案

1、安装插件  安装 amfe-flexible、postcss-px2rem-exclude cnpm i amfe-flexible postcss-px2rem-exclude --save 安装完毕,会在 package.json 文件的 dependencies 属性中看到如下: 2、在main.js文件中引入 import 'amfe-fle...

vue 权限管理怎么做

前言 在一个项目中,一些功能会涉及到重要的数据管理,为了确保数据的安全,我们会在项目中加入权限来限制每个用户的操作。作为前端,我们要做的是配合后端给到的权限数据,做页面上的各种各样的限制。 需求 因为这是一个工作上的业务需求,所以对于我来说主要有两个地方需要进行权限控制。 第一个是侧边菜单栏,需要控制显示与隐藏。 第二个就是页面内的各个按钮,弹窗等。 流程...

Vue通过build打包后 打开index.html页面是空白的

最近在build打包vue项目遇到了几个问题,如下: 1、npm run build打包项目之后,我们通常是把dist文件里面被压缩后的static文件跟index.html提交到服务器,但最近发现直接打开index.html页面是空白的,还会报几个错,找不到页面路径。 原因:找到config文件下index.js,全局搜索assetsPublicPath...

npm run dev 报错:missing script:dev

学习Vue-CLI时,使用命令npm run dev报错: 解决 查看了vue项目中的package.json文件,我的scrip参数信息: 在script里,并没有dev,而是serve,应该用npm run serve命令运行vue项目即可。...

鼠标悬浮显示鼠标停留数据的内容 elementui + vue

先看效果图 直接上代码 <el-tabs v-model="activeName" @tab-click="handleClick"> <el-tab-pane :label="speaker.abscissa[0]" name="first"> <div...

# Vue 使用树形穿梭框

Vue 使用树形穿梭框 Vue 项目里面需要一个树形的穿梭框,但是 elementUI 和 ant-d 组件库的穿梭框组件效果都不是很好,因为源列表和目标列表都是需要树形结构的,所以说这个就很难搞,但是也不怕,因为大佬太多了,有插件可以提供给我们使用,接下来介绍一下这个插件。 树形穿梭框插件 el-tree-transfer 这个插件很好的实现了vue项...