本文实例为大家分享了vue实现底部弹窗多选的具体代码,供大家参考,具体内容如下
代码:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427<template> <div class="release-post"> <div class="resume_main"> <div class="resume_content"> <van-form> <div class="table_list post_welfare"> <p class="name_title">岗位福利<span class="required">*</span></p> <van-field class="calendar" input-align="left" v-model="benefits" placeholder="请选择岗位福利" @focus="onFocus" :class="{ borderStyle: welfareChange }" @click.stop="clickWelfare" :disabled="true" /> </div> </van-form> <!-- 岗位福利 --> <van-popup v-model="showWelfare" position="bottom"> <div class="welfare_top"> <p></p> <p class="welfare_title">福利待遇(可多选)</p> <p class="welfare_btn" @click.stop="onConfirmSpeed">完成</p> </div> <div class="welfare_content"> <div v-for="(item, index) in welfareList" :key="index" :class="{ active: item.active }" id="welfare_item" @click.stop="clickWelfareItem(item, index)" > <p :class="item.active ? 'welfare_text' : 'not_welfare_text'"> {{ item.text }} </p> </div> </div> </van-popup> </div> </div> <div> <div class="mask"> <button class="btn" @click="submit" :class="{ btnBg: colorChange() }" v-preventReClick="1000" > 完成 </button> </div> </div> </div> </template> <script> import Vue from 'vue'; import { Circle, DatetimePicker, Form, Field, Toast, Calendar, Picker, Overlay, ActionSheet, Popup } from 'vant'; import 'vant/lib/index.less'; Vue.use(Circle).use(DatetimePicker).use(Form).use(Field).use(Toast).use(Calendar).use(Picker).use(Overlay).use(ActionSheet).use(Popup); export default { name: "PerfectPost", data () { return { welfareList: [ { id: 1, text: "包吃" }, { id: 2, text: "包住" }, { id: 3, text: "五险一金" }, { id: 4, text: "年底双薪" }, { id: 5, text: "商业险" }, { id: 6, text: "意外险" }, { id: 7, text: "团建" }, { id: 8, text: "周末双休" }, { id: 9, text: "下午茶" }, { id: 10, text: "餐补" }, { id: 11, text: "交通补助" }, { id: 12, text: "班车接送" }, { id: 13, text: "奖金" }, { id: 14, text: "公费培训" }, { id: 15, text: "公费旅游" }, ], showWelfare: false,//岗位福利 onlineForm: { benefits: "",//岗位福利 }, checkedList: [], welfareChange: false, }; }, methods: { //弹出岗位福利 clickWelfare () { this.showRedTips() this.showWelfare = true }, //选择福利项 clickWelfareItem (v) { if (v.active) { Vue.set(v, 'active', false) } else if (this.checkedList.length < 5) { Vue.set(v, 'active', true) } this.checkedList = this.welfareList.filter(function (item) { return item.active }) if (this.checkedList.length >= 5) { Toast('最多只能选择5个哦') } }, //完成福利选项 onConfirmSpeed () { this.showWelfare = false this.welfareChange = false let itemList = this.checkedList.map((item) => { return item.text }); let str = itemList.join('/') let str1 = itemList.join(';') this.benefits = str ? str : this.benefits this.onlineForm.benefits = str1 ? str1 : this.benefits }, showRedTips () { this.welfareChange = false }, onFocus () { this.showRedTips() }, //下一步按钮色值 colorChange () { if (this.onlineForm.benefits) { return true } }, // 验证 validateOnlineForm () { let valid = true; if (!this.onlineForm.benefits || !this.onlineForm.benefits.trim()) { valid = false; Toast('请选择岗位福利') this.welfareChange = true } return valid; }, //提交 submit () { if (this.validateOnlineForm()) { Toast('提交') } }, }, }; </script> <style scoped lang="less" > * { margin: 0; padding: 0; } ::v-deep .van-picker__title { font-size: 17px; font-family: PingFangSC, PingFangSC-Medium; font-weight: 500; text-align: center; color: #333333; } .release-post { width: 100%; padding-bottom: 64px; padding-top: constant(safe-area-inset-top); padding-top: env(safe-area-inset-top); } .post_welfare { ::v-deep .van-field__control:disabled { font-size: 15px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: left; color: #333333; -webkit-text-fill-color: #333333; } ::v-deep input::-webkit-input-placeholder { font-size: 15px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: left; color: #999999; -webkit-text-fill-color: #999999; } } ::v-deep .van-field__control:disabled { font-size: 15px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: left; color: #333333; -webkit-text-fill-color: #333333; } .welfare_content { padding-top: 10px; padding-bottom: 30px; display: flex; justify-content: space-around; align-items: center; flex-wrap: wrap; margin: 0 16px; } #welfare_item { width: 31%; } .welfare_top { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: solid 0.5px #e5e5e5; } .welfare_title { font-size: 17px; font-family: PingFangSC, PingFangSC-Medium; font-weight: 500; text-align: center; color: #333333; margin-right: -16px; } .welfare_btn { font-size: 16px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: right; color: #333333; margin-right: 16px; } .welfare_text { height: 36px; background: #f4f8ff; border: 1px solid #bbdcff; border-radius: 4px; margin-top: 10px; line-height: 36px; font-size: 14px; font-family: PingFangSC, PingFangSC-Medium; font-weight: 500; text-align: center; color: #1283ff; } .not_welfare_text { height: 36px; background: #ffffff; border: 1px solid #e5e5e5; border-radius: 4px; margin-top: 10px; line-height: 36px; font-size: 14px; font-family: PingFang, PingFang-SC; font-weight: 500; text-align: center; color: #333333; } .resume_content { margin-left: 30px; margin-right: 30px; ::v-deep { .van-popup--bottom { border-top-left-radius: 12px; border-top-right-radius: 12px; } } } .mask { width: 100%; background: #ffffff; box-shadow: 0px 0px 8px 0px rgba(204, 204, 204, 0.3); position: fixed; bottom: 0; left: 0; display: flex; justify-content: center; align-items: center; padding: 10px 0; padding-bottom: calc(env(safe-area-inset-bottom)+15px); padding-bottom: calc(env(safe-area-inset-bottom) + 15px); } .btn { font-size: 16px; font-family: PingFangSC, PingFangSC-Medium; font-weight: 500; text-align: left; color: #ffffff; margin: 0 auto; text-align: center; line-height: 1.6rem; width: 100%; margin: 0 16px; height: 48px; background: #d8d8d8; } .btnBg { font-size: 16px; font-family: PingFangSC, PingFangSC-Medium; font-weight: 500; text-align: left; color: #ffffff; margin: 0 auto; text-align: center; line-height: 1.6rem; width: 100%; margin: 0 16px; height: 48px; background: #d8d8d8; border: none; outline: none; background: linear-gradient(90deg, #50a3ff, #1283ff); border-radius: 4px; } .name_title { font-size: 16px; font-family: PingFangSC, PingFangSC-Medium; font-weight: 500; color: #333333; } .required { font-size: 13px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; color: #ff1d28; position: absolute; } .calendar { width: 100%; height: 49px; background: #ffffff; border: 1px solid #e5e5e5; border-radius: 5px; margin-top: 10px; padding-left: 20px; background: url("./images/drop-down.png") no-repeat 96% center; background-size: 10px 7px; padding-right: 25px; ::v-deep .van-field__control { font-size: 15px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: left; color: #333333; margin-top: 12px; } } ::v-deep input::-webkit-input-placeholder { font-size: 15px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: left; color: #afadad; -webkit-text-fill-color: #afadad; } .table_list { margin-top: 16px; } .borderStyle { border: solid 1px #ff1d28; border-radius: 3px; } input::-webkit-input-placeholder { font-size: 15px; font-family: PingFangSC, PingFangSC-Regular; font-weight: 400; text-align: left; color: #999999; } .van-field__control { color: #333333; } </style>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持靠谱客。
最后
以上就是轻松抽屉最近收集整理的关于vue实现底部弹窗多选的全部内容,更多相关vue实现底部弹窗多选内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复