• vant 的 Cascader 级联选择 组建css样式错乱问题修复


    vant 的 Cascader 级联选择 组建css样式错乱问题修复

    未修复的效果

    修复后的效果

     

    修复需要的css代码

    1. /*级联控件 start*/
    2. .cplvfx .van-popup {
    3. position: fixed;
    4. max-height: 100%;
    5. overflow-y: auto;
    6. background-color: #fff;
    7. -webkit-transition: -webkit-transform 0.3s;
    8. transition: -webkit-transform 0.3s;
    9. transition: transform 0.3s;
    10. transition: transform 0.3s, -webkit-transform 0.3s;
    11. -webkit-overflow-scrolling: touch;
    12. }
    13. .cplvfx .van-popup--center {
    14. top: 50%;
    15. left: 50%;
    16. -webkit-transform: translate3d(-50%, -50%, 0);
    17. transform: translate3d(-50%, -50%, 0);
    18. }
    19. .cplvfx .van-popup--center.van-popup--round {
    20. border-radius: 16px;
    21. }
    22. .cplvfx .van-popup--top {
    23. top: 0;
    24. left: 0;
    25. width: 100%;
    26. }
    27. .cplvfx .van-popup--top.van-popup--round {
    28. border-radius: 0 0 16px 16px;
    29. }
    30. .cplvfx .van-popup--right {
    31. top: 50%;
    32. right: 0;
    33. -webkit-transform: translate3d(0, -50%, 0);
    34. transform: translate3d(0, -50%, 0);
    35. }
    36. .cplvfx .van-popup--right.van-popup--round {
    37. border-radius: 16px 0 0 16px;
    38. }
    39. .cplvfx .van-popup--bottom {
    40. bottom: 0;
    41. left: 0;
    42. width: 100%;
    43. }
    44. .cplvfx .van-popup--bottom.van-popup--round {
    45. border-radius: 16px 16px 0 0;
    46. }
    47. .cplvfx .van-popup--left {
    48. top: 50%;
    49. left: 0;
    50. -webkit-transform: translate3d(0, -50%, 0);
    51. transform: translate3d(0, -50%, 0);
    52. }
    53. .cplvfx .van-popup--left.van-popup--round {
    54. border-radius: 0 16px 16px 0;
    55. }
    56. .cplvfx .van-popup--safe-area-inset-bottom {
    57. padding-bottom: constant(safe-area-inset-bottom);
    58. padding-bottom: env(safe-area-inset-bottom);
    59. }
    60. .cplvfx .van-popup-slide-top-enter-active,
    61. .cplvfx .van-popup-slide-left-enter-active,
    62. .cplvfx .van-popup-slide-right-enter-active,
    63. .cplvfx .van-popup-slide-bottom-enter-active {
    64. -webkit-transition-timing-function: ease-out;
    65. transition-timing-function: ease-out;
    66. }
    67. .cplvfx .van-popup-slide-top-leave-active,
    68. .cplvfx .van-popup-slide-left-leave-active,
    69. .cplvfx .van-popup-slide-right-leave-active,
    70. .cplvfx .van-popup-slide-bottom-leave-active {
    71. -webkit-transition-timing-function: ease-in;
    72. transition-timing-function: ease-in;
    73. }
    74. .cplvfx .van-popup-slide-top-enter,
    75. .cplvfx .van-popup-slide-top-leave-active {
    76. -webkit-transform: translate3d(0, -100%, 0);
    77. transform: translate3d(0, -100%, 0);
    78. }
    79. .cplvfx .van-popup-slide-right-enter,
    80. .cplvfx .van-popup-slide-right-leave-active {
    81. -webkit-transform: translate3d(100%, -50%, 0);
    82. transform: translate3d(100%, -50%, 0);
    83. }
    84. .cplvfx .van-popup-slide-bottom-enter,
    85. .cplvfx .van-popup-slide-bottom-leave-active {
    86. -webkit-transform: translate3d(0, 100%, 0);
    87. transform: translate3d(0, 100%, 0);
    88. }
    89. .cplvfx .van-popup-slide-left-enter,
    90. .cplvfx .van-popup-slide-left-leave-active {
    91. -webkit-transform: translate3d(-100%, -50%, 0);
    92. transform: translate3d(-100%, -50%, 0);
    93. }
    94. .cplvfx .van-popup__close-icon {
    95. position: absolute;
    96. z-index: 1;
    97. color: #c8c9cc;
    98. font-size: 22px;
    99. cursor: pointer;
    100. }
    101. .cplvfx .van-popup__close-icon:active {
    102. color: #969799;
    103. }
    104. .cplvfx .van-popup__close-icon--top-left {
    105. top: 16px;
    106. left: 16px;
    107. }
    108. .cplvfx .van-popup__close-icon--top-right {
    109. top: 16px;
    110. right: 16px;
    111. }
    112. .cplvfx .van-popup__close-icon--bottom-left {
    113. bottom: 16px;
    114. left: 16px;
    115. }
    116. .cplvfx .van-popup__close-icon--bottom-right {
    117. right: 16px;
    118. bottom: 16px;
    119. }
    120. .cplvfx .van-calendar__popup.van-popup--top,
    121. .cplvfx .van-calendar__popup.van-popup--bottom {
    122. height: 80%;
    123. }
    124. .cplvfx .van-calendar__popup.van-popup--left,
    125. .cplvfx .van-calendar__popup.van-popup--right {
    126. height: 100%;
    127. }
    128. .cplvfx .van-calendar__popup .van-popup__close-icon {
    129. top: 11px;
    130. }
    131. .cplvfx .demo-contact-card .van-popup {
    132. height: 100%;
    133. background-color: #f7f8fa;
    134. }
    135. .cplvfx .van-cascader__header {
    136. display: -webkit-box;
    137. display: -webkit-flex;
    138. display: flex;
    139. -webkit-box-align: center;
    140. -webkit-align-items: center;
    141. align-items: center;
    142. -webkit-box-pack: justify;
    143. -webkit-justify-content: space-between;
    144. justify-content: space-between;
    145. height: 48px;
    146. padding: 0 16px;
    147. }
    148. .cplvfx .van-cascader__title {
    149. font-weight: 500;
    150. font-size: 16px;
    151. line-height: 20px;
    152. }
    153. .cplvfx .van-cascader__close-icon {
    154. color: #c8c9cc;
    155. font-size: 22px;
    156. }
    157. .cplvfx .van-cascader__close-icon:active {
    158. color: #969799;
    159. }
    160. .cplvfx .van-cascader__tabs .van-tab {
    161. -webkit-box-flex: 0;
    162. -webkit-flex: none;
    163. flex: none;
    164. padding: 0 10px;
    165. }
    166. .cplvfx .van-cascader__tabs.van-tabs--line .van-tabs__wrap {
    167. height: 48px;
    168. }
    169. .cplvfx .van-cascader__tabs .van-tabs__nav--complete {
    170. padding-right: 6px;
    171. padding-left: 6px;
    172. }
    173. .cplvfx .van-cascader__tab {
    174. color: #323233;
    175. font-weight: 500;
    176. }
    177. .cplvfx .van-cascader__tab--unselected {
    178. color: #969799;
    179. font-weight: normal;
    180. }
    181. .cplvfx .van-cascader__option {
    182. display: -webkit-box;
    183. display: -webkit-flex;
    184. display: flex;
    185. -webkit-box-align: center;
    186. -webkit-align-items: center;
    187. align-items: center;
    188. -webkit-box-pack: justify;
    189. -webkit-justify-content: space-between;
    190. justify-content: space-between;
    191. padding: 10px 16px;
    192. font-size: 14px;
    193. line-height: 20px;
    194. }
    195. .cplvfx .van-cascader__option:active {
    196. background-color: #f2f3f5;
    197. }
    198. .cplvfx .van-cascader__option--selected {
    199. color: #ee0a24;
    200. font-weight: 500;
    201. }
    202. .cplvfx .van-cascader__selected-icon {
    203. font-size: 18px;
    204. }
    205. .cplvfx .van-cascader__options {
    206. box-sizing: border-box;
    207. height: 384px;
    208. padding-top: 6px;
    209. overflow-y: auto;
    210. -webkit-overflow-scrolling: touch;
    211. }
    212. /*级联控件 end*/

     

    html代码

    1. <div class="cplvfx">
    2. <van-field
    3. v-model="AddVal"
    4. is-link
    5. readonly
    6. placeholder="请选择活动地区"
    7. @click="SelectAddStatus = true"
    8. />
    9. <van-popup v-model="SelectAddStatus" round position="bottom">
    10. <van-cascader
    11. v-model="SelectAddVal"
    12. title="请选择所在地区"
    13. :options="AreaData"
    14. active-color="#17BF8C"
    15. @close="SelectAddStatus = false"
    16. @change="AddSelectChange"
    17. @finish="AddSelectFinish"
    18. />
    19. </van-popup>
    20. </div>

    js 代码

    一,引入必要组建

    1. import { Popup } from 'vant';
    2. import { Cascader } from 'vant';
    3. import { Field } from 'vant';
    4. Vue.use(Popup);
    5. Vue.use(Cascader);
    6. Vue.use(Field);

    二、参数

    1. export default {
    2. data(){
    3. return{
    4. SelectAddStatus:false,//地址选择状态
    5. SelectAddVal:'',//地址值
    6. AddVal:'',//地址值
    7. }
    8. },
    9. created:(){},
    10. methods:{
    11. //地址选择发生变化
    12. AddSelectChange({ value, selectedOptions, tabIndex }){
    13. console.log('地址选择发生变化');
    14. console.log(value);
    15. console.log(selectedOptions);
    16. console.log(tabIndex);
    17. },
    18. //地址选择完成
    19. AddSelectFinish({ value, selectedOptions, tabIndex }){
    20. console.log('地址选择完成');
    21. console.log(value);
    22. console.log(selectedOptions);
    23. console.log(tabIndex);
    24. this.SelectAddStatus = false;
    25. this.AddVal = selectedOptions.map((option) => option.text).join('/');
    26. console.log('this.SelectAddVal===');
    27. console.log(this.SelectAddVal);
    28. console.log('this.AddVal===');
    29. console.log(this.AddVal );
    30. }
    31. },
    32. }

    延伸阅读

    vue 页面的css样式代码多,怎么把css样式代码做成独立的文件,然后引用进来;以及style的scoped标签介绍以及scoped穿透介绍

    vue 页面的css样式代码多,怎么把css样式代码做成独立的文件,然后引用进来;以及style的scoped标签介绍以及scoped穿透介绍_cplvfx的博客-CSDN博客vue 页面的css样式代码多,怎么把css样式代码做成独立的文件,然后引用进来;以及style的scoped标签介绍以及scoped穿透介绍https://blog.csdn.net/cplvfx/article/details/125521371

  • 相关阅读:
    [山东科技大学OJ]1382 Problem A: 编写函数:三个数的最大最小值 (Append Code)
    克鲁斯卡尔算法(C++)
    Jira Bug管理工具的操作步骤 提Bug的流程
    JMETER实战从创建测试数据到分布式压测测试全流程
    sql语句,分组后,组内根据datetime字段排序,保留日期最新的一条组内记录,删除其他项。(用于组内重复数据的剔除)
    JDK源码分析实战系列-PriorityQueue
    【牛客网-前端笔试题】——vue专项练习
    【目标检测】SSD损失函数详解
    洛谷P3369 【模板】普通平衡树 红黑树实现
    载誉前行 | 求臻医学MRD检测方案荣获金如意奖·卓越奖
  • 原文地址:https://blog.csdn.net/cplvfx/article/details/125522167