vue實(shí)現(xiàn)底部彈窗多選
本文實(shí)例為大家分享了vue實(shí)現(xiàn)底部彈窗多選的具體代碼,供大家參考,具體內(nèi)容如下
代碼:
<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="請(qǐng)選擇崗位福利" @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: "五險(xiǎn)一金" }, { id: 4, text: "年底雙薪" }, { id: 5, text: "商業(yè)險(xiǎn)" }, { id: 6, text: "意外險(xiǎn)" }, { id: 7, text: "團(tuán)建" }, { id: 8, text: "周末雙休" }, { id: 9, text: "下午茶" }, { id: 10, text: "餐補(bǔ)" }, { id: 11, text: "交通補(bǔ)助" }, { id: 12, text: "班車(chē)接送" }, { id: 13, text: "獎(jiǎng)金" }, { id: 14, text: "公費(fèi)培訓(xùn)" }, { id: 15, text: "公費(fèi)旅游" }, ], showWelfare: false,//崗位福利 onlineForm: { benefits: "",//崗位福利 }, checkedList: [], welfareChange: false, }; }, methods: { //彈出崗位福利 clickWelfare () { this.showRedTips() this.showWelfare = true }, //選擇福利項(xiàng) 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個(gè)哦') } }, //完成福利選項(xiàng) 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 } }, // 驗(yàn)證 validateOnlineForm () { let valid = true; if (!this.onlineForm.benefits || !this.onlineForm.benefits.trim()) { valid = false; Toast('請(qǐng)選擇崗位福利') 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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 使用Vue組件實(shí)現(xiàn)一個(gè)簡(jiǎn)單彈窗效果
- 關(guān)于vue.js彈窗組件的知識(shí)點(diǎn)總結(jié)
- 很棒的vue彈窗組件
- vue彈窗消息組件的使用方法
- VUE實(shí)現(xiàn)可隨意拖動(dòng)的彈窗組件
- vue實(shí)現(xiàn)點(diǎn)擊按鈕“查看詳情”彈窗展示詳情列表操作
- vue的toast彈窗組件實(shí)例詳解
- Vue中關(guān)閉彈窗組件時(shí)銷(xiāo)毀并隱藏操作
- vue 彈窗時(shí) 監(jiān)聽(tīng)手機(jī)返回鍵關(guān)閉彈窗功能(頁(yè)面不跳轉(zhuǎn))
- 使用VUE實(shí)現(xiàn)在table中文字信息超過(guò)5個(gè)隱藏鼠標(biāo)移到時(shí)彈窗顯示全部
相關(guān)文章
element step組件在另一側(cè)加時(shí)間軸顯示
本文主要介紹了element step組件在另一側(cè)加時(shí)間軸顯示,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06vue3中如何使用Pinia實(shí)現(xiàn)數(shù)據(jù)持久化操作
使用vue3中的pinia,我們可以在多個(gè)頁(yè)面間共享數(shù)據(jù),但是一旦我們關(guān)閉或刷新頁(yè)面,這些數(shù)據(jù)就會(huì)丟失,因此,我們需要有一種數(shù)據(jù)持久化的解決方案,下面我們就來(lái)看看具體如何解決的吧2023-10-10vue 手機(jī)物理監(jiān)聽(tīng)鍵+退出提示代碼
這篇文章主要介紹了vue 手機(jī)物理監(jiān)聽(tīng)鍵+退出提示代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-09-09vue增加強(qiáng)緩存和版本號(hào)的實(shí)現(xiàn)方法
這篇文章主要介紹了vue增加強(qiáng)緩存和版本號(hào)的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05Vue3源碼分析reactivity實(shí)現(xiàn)方法示例
這篇文章主要為大家介紹了Vue3源碼分析reactivity實(shí)現(xiàn)方法原理示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01vue如何使用 Slot 分發(fā)內(nèi)容實(shí)例詳解
本篇文章主要介紹了vue如何使用 Slot 分發(fā)內(nèi)容實(shí)例詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-09-09Vue CLI3移動(dòng)端適配(px2rem或postcss-plugin-px2rem)
這篇文章主要介紹了Vue CLI3移動(dòng)端適配(px2rem或postcss-plugin-px2rem),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04