解決vant的Cascader級聯(lián)選擇組建css樣式錯(cuò)亂問題
更新時(shí)間:2024年07月02日 09:02:33 作者:橙-極紀(jì)元JJY.Cheng
這篇文章主要介紹了解決vant的Cascader級聯(lián)選擇組建css樣式錯(cuò)亂問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
未修復(fù)的效果
修復(fù)后的效果
修復(fù)需要的css代碼
/*級聯(lián)控件 start*/ .cplvfx .van-popup { position: fixed; max-height: 100%; overflow-y: auto; background-color: #fff; -webkit-transition: -webkit-transform 0.3s; transition: -webkit-transform 0.3s; transition: transform 0.3s; transition: transform 0.3s, -webkit-transform 0.3s; -webkit-overflow-scrolling: touch; } .cplvfx .van-popup--center { top: 50%; left: 50%; -webkit-transform: translate3d(-50%, -50%, 0); transform: translate3d(-50%, -50%, 0); } .cplvfx .van-popup--center.van-popup--round { border-radius: 16px; } .cplvfx .van-popup--top { top: 0; left: 0; width: 100%; } .cplvfx .van-popup--top.van-popup--round { border-radius: 0 0 16px 16px; } .cplvfx .van-popup--right { top: 50%; right: 0; -webkit-transform: translate3d(0, -50%, 0); transform: translate3d(0, -50%, 0); } .cplvfx .van-popup--right.van-popup--round { border-radius: 16px 0 0 16px; } .cplvfx .van-popup--bottom { bottom: 0; left: 0; width: 100%; } .cplvfx .van-popup--bottom.van-popup--round { border-radius: 16px 16px 0 0; } .cplvfx .van-popup--left { top: 50%; left: 0; -webkit-transform: translate3d(0, -50%, 0); transform: translate3d(0, -50%, 0); } .cplvfx .van-popup--left.van-popup--round { border-radius: 0 16px 16px 0; } .cplvfx .van-popup--safe-area-inset-bottom { padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom); } .cplvfx .van-popup-slide-top-enter-active, .cplvfx .van-popup-slide-left-enter-active, .cplvfx .van-popup-slide-right-enter-active, .cplvfx .van-popup-slide-bottom-enter-active { -webkit-transition-timing-function: ease-out; transition-timing-function: ease-out; } .cplvfx .van-popup-slide-top-leave-active, .cplvfx .van-popup-slide-left-leave-active, .cplvfx .van-popup-slide-right-leave-active, .cplvfx .van-popup-slide-bottom-leave-active { -webkit-transition-timing-function: ease-in; transition-timing-function: ease-in; } .cplvfx .van-popup-slide-top-enter, .cplvfx .van-popup-slide-top-leave-active { -webkit-transform: translate3d(0, -100%, 0); transform: translate3d(0, -100%, 0); } .cplvfx .van-popup-slide-right-enter, .cplvfx .van-popup-slide-right-leave-active { -webkit-transform: translate3d(100%, -50%, 0); transform: translate3d(100%, -50%, 0); } .cplvfx .van-popup-slide-bottom-enter, .cplvfx .van-popup-slide-bottom-leave-active { -webkit-transform: translate3d(0, 100%, 0); transform: translate3d(0, 100%, 0); } .cplvfx .van-popup-slide-left-enter, .cplvfx .van-popup-slide-left-leave-active { -webkit-transform: translate3d(-100%, -50%, 0); transform: translate3d(-100%, -50%, 0); } .cplvfx .van-popup__close-icon { position: absolute; z-index: 1; color: #c8c9cc; font-size: 22px; cursor: pointer; } .cplvfx .van-popup__close-icon:active { color: #969799; } .cplvfx .van-popup__close-icon--top-left { top: 16px; left: 16px; } .cplvfx .van-popup__close-icon--top-right { top: 16px; right: 16px; } .cplvfx .van-popup__close-icon--bottom-left { bottom: 16px; left: 16px; } .cplvfx .van-popup__close-icon--bottom-right { right: 16px; bottom: 16px; } .cplvfx .van-calendar__popup.van-popup--top, .cplvfx .van-calendar__popup.van-popup--bottom { height: 80%; } .cplvfx .van-calendar__popup.van-popup--left, .cplvfx .van-calendar__popup.van-popup--right { height: 100%; } .cplvfx .van-calendar__popup .van-popup__close-icon { top: 11px; } .cplvfx .demo-contact-card .van-popup { height: 100%; background-color: #f7f8fa; } .cplvfx .van-cascader__header { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; height: 48px; padding: 0 16px; } .cplvfx .van-cascader__title { font-weight: 500; font-size: 16px; line-height: 20px; } .cplvfx .van-cascader__close-icon { color: #c8c9cc; font-size: 22px; } .cplvfx .van-cascader__close-icon:active { color: #969799; } .cplvfx .van-cascader__tabs .van-tab { -webkit-box-flex: 0; -webkit-flex: none; flex: none; padding: 0 10px; } .cplvfx .van-cascader__tabs.van-tabs--line .van-tabs__wrap { height: 48px; } .cplvfx .van-cascader__tabs .van-tabs__nav--complete { padding-right: 6px; padding-left: 6px; } .cplvfx .van-cascader__tab { color: #323233; font-weight: 500; } .cplvfx .van-cascader__tab--unselected { color: #969799; font-weight: normal; } .cplvfx .van-cascader__option { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; padding: 10px 16px; font-size: 14px; line-height: 20px; } .cplvfx .van-cascader__option:active { background-color: #f2f3f5; } .cplvfx .van-cascader__option--selected { color: #ee0a24; font-weight: 500; } .cplvfx .van-cascader__selected-icon { font-size: 18px; } .cplvfx .van-cascader__options { box-sizing: border-box; height: 384px; padding-top: 6px; overflow-y: auto; -webkit-overflow-scrolling: touch; } /*級聯(lián)控件 end*/
html代碼
注意:父容器需要加 <div class="cplvfx">
<div class="cplvfx"> <van-field v-model="AddVal" is-link readonly placeholder="請選擇活動(dòng)地區(qū)" @click="SelectAddStatus = true" /> <van-popup v-model="SelectAddStatus" round position="bottom"> <van-cascader v-model="SelectAddVal" title="請選擇所在地區(qū)" :options="AreaData" active-color="#17BF8C" @close="SelectAddStatus = false" @change="AddSelectChange" @finish="AddSelectFinish" /> </van-popup> </div>
js 代碼
一、引入必要組建
import { Popup } from 'vant'; import { Cascader } from 'vant'; import { Field } from 'vant'; Vue.use(Popup); Vue.use(Cascader); Vue.use(Field);
二、參數(shù)
export default { data(){ return{ SelectAddStatus:false,//地址選擇狀態(tài) SelectAddVal:'',//地址值 AddVal:'',//地址值 } }, created:(){}, methods:{ //地址選擇發(fā)生變化 AddSelectChange({ value, selectedOptions, tabIndex }){ console.log('地址選擇發(fā)生變化'); console.log(value); console.log(selectedOptions); console.log(tabIndex); }, //地址選擇完成 AddSelectFinish({ value, selectedOptions, tabIndex }){ console.log('地址選擇完成'); console.log(value); console.log(selectedOptions); console.log(tabIndex); this.SelectAddStatus = false; this.AddVal = selectedOptions.map((option) => option.text).join('/'); console.log('this.SelectAddVal==='); console.log(this.SelectAddVal); console.log('this.AddVal==='); console.log(this.AddVal ); } }, }
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
簡單了解Vue computed屬性及watch區(qū)別
這篇文章主要介紹了通過實(shí)例解析Vue computed屬性及watch區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07vue數(shù)組動(dòng)態(tài)刷新失敗問題及解決
這篇文章主要介紹了vue數(shù)組動(dòng)態(tài)刷新失敗問題及解決,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03vue之a(chǎn)-table中實(shí)現(xiàn)清空選中的數(shù)據(jù)
今天小編就為大家分享一篇vue之a(chǎn)-table中實(shí)現(xiàn)清空選中的數(shù)據(jù),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11