c-picker


底部弹起的滚动选择器

示例

  1. <template>
  2. <page title="c-picker 演示">
  3. <view>
  4. <text class="select-text" c-bind:tap="showClick">点击选择:{{column[columnIndex]}}</text>
  5. <c-picker
  6. show="{{pickerShow}}"
  7. title="请选择"
  8. header-height="{{100}}"
  9. text-align="center"
  10. data-height="{{400}}"
  11. list="{{column}}"
  12. default-index="{{defaultIndex}}"
  13. c-bind:cancel="cancel"
  14. c-bind:confirm="confirm"
  15. c-bind:selectchange="selectchange">
  16. </c-picker>
  17. </view>
  18. </page>
  19. </template>
  20. <script>
  21. class Index {
  22. data = {
  23. column: [
  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. defaultIndex: 0,
  57. columnIndex: 0,
  58. pickerShow: false
  59. }
  60. methods = {
  61. selectchange(e) {
  62. this.columnIndex = this.defaultIndex = e.detail.index;
  63. },
  64. showClick() {
  65. this.pickerShow = true;
  66. },
  67. cancel() {
  68. this.pickerShow = false;
  69. },
  70. confirm() {
  71. this.pickerShow = false;
  72. }
  73. }
  74. };
  75. export default new Index();
  76. </script>
  77. <style scoped>
  78. .select-text {
  79. display: flex;
  80. justify-content: center;
  81. align-items: center;
  82. font-size: 32cpx;
  83. text-align: center;
  84. }
  85. </style>
  86. <script cml-type="json">
  87. {
  88. "base": {
  89. "usingComponents": {
  90. "c-picker": "cml-ui/components/c-picker/c-picker"
  91. }
  92. }
  93. }
  94. </script>