c-picker-panel


从底部弹起的控制板。

属性

属性名类型必填默认值说明
showBooleanfalse是否点击打开底部控制板
titleString"请选择"控制板的标题
header-heightNumber100底部控制板标题栏的高度
cancel-btn-styleString自定义取消按钮的样式,如 "color:red;text-align:center;"
confirm-btn-styleString自定义确定按钮的样式,如 "color:red;text-align:center;"
c-bind:cancelEventHandle用户点击"取消"时触发:返回事件对象:event.type="cancel"
c-bind:confirmEventHandle用户点击"确定"时触发:返回事件对象:event.type="confirm"

示例

c-picker-panel
  1. <template>
  2. <page title="c-picker-panel演示">
  3. <view class="container">
  4. <text class="select-text" c-bind:tap="showClick">点击选择:{{provins[provinsIndex]}}</text>
  5. <c-picker-panel
  6. show="{{panelShow}}"
  7. height="{{500}}"
  8. header-height="{{100}}"
  9. c-bind:cancel="cancel"
  10. c-bind:confirm="confirm">
  11. <c-picker-item
  12. text-align="center"
  13. height="{{400}}"
  14. list="{{provins}}"
  15. default-index="{{defaultIndex}}"
  16. c-bind:selectchange="selectchange">
  17. </c-picker-item>
  18. </c-picker-panel>
  19. </view>
  20. </page>
  21. </template>
  22. <script>
  23. import { provins } from "./data";
  24. class CPickerPanel {
  25. data = {
  26. provins: [
  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. defaultIndex: 0,
  60. provinsIndex: 0,
  61. panelShow: false
  62. }
  63. computed = {}
  64. watch = {}
  65. methods = {
  66. selectchange(e) {
  67. this.provinsIndex = this.defaultIndex = e.detail.index;
  68. },
  69. showClick() {
  70. this.panelShow = true;
  71. },
  72. cancel() {
  73. this.panelShow = false;
  74. },
  75. confirm() {
  76. this.panelShow = false;
  77. }
  78. }
  79. beforeCreate() {}
  80. created() {}
  81. beforeMount() {}
  82. mounted() {}
  83. beforeDestroy() {}
  84. destroyed() {}
  85. }
  86. export default new CPickerPanel();
  87. </script>
  88. <style scoped>
  89. .container {
  90. background: #f8f8f8;
  91. position: absolute;
  92. top: 88cpx;
  93. bottom: 0;
  94. left: 0;
  95. right: 0;
  96. }
  97. .page-demo {
  98. background: #fafafa;
  99. position: absolute;
  100. top: 0;
  101. bottom: 0;
  102. left: 0;
  103. right: 0;
  104. }
  105. .title-text {
  106. color: #999;
  107. margin: 30cpx 20cpx 10cpx;
  108. display: block;
  109. font-size: 28cpx;
  110. }
  111. .picker-item {
  112. background: #fff;
  113. border-top: 1px solid #d9d9d9;
  114. border-bottom: 1px solid #d9d9d9;
  115. display: flex;
  116. flex-direction: row;
  117. }
  118. .picker-text-left {
  119. font-size: 40cpx;
  120. height: 70cpx;
  121. line-height: 70cpx;
  122. margin-left: 20cpx;
  123. width: 300cpx;
  124. }
  125. .picker-text-right {
  126. font-size: 40cpx;
  127. height: 70cpx;
  128. line-height: 70cpx;
  129. margin-left: 20cpx;
  130. flex: 1;
  131. text-align: center;
  132. }
  133. .select-text {
  134. font-size: 32cpx;
  135. text-align: center;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. }
  140. </style>
  141. <script cml-type="json">
  142. {
  143. "base": {
  144. "usingComponents": {
  145. "c-picker-panel": "cml-ui/components/c-picker-panel/c-picker-panel",
  146. "c-picker-item": "cml-ui/components/c-picker-item/c-picker-item"
  147. }
  148. }
  149. }
  150. </script>

c-picker-panel  - 图1wx

c-picker-panel  - 图2web

c-picker-panel  - 图3native