c-picker-item


滚动选择器

属性

属性名类型必填默认值说明
listArray['']滚动选择器滚动的数据,注意:data 属性名已废弃
default-indexNumber0滚动选择器默认的数据索引
heightNumber400滚动选择器的高度
text-alignString"center"滚动选择器的文本样式:"居中"
c-bind:selectchangeEventHandle 选择器滚动时触发: 返回事件对象: event.type="selectchange" event.detail = {index}

示例

  1. <template>
  2. <page title="c-picker-item演示">
  3. <view class="container">
  4. <text class="select-text">选择的值:{{provins[provinsIndex]}}</text>
  5. <c-picker-item
  6. text-align="center"
  7. height="{{400}}"
  8. list="{{provins}}"
  9. default-index="{{defaultIndex}}"
  10. c-bind:selectchange="selectchange"
  11. >
  12. </c-picker-item>
  13. </view>
  14. </page>
  15. </template>
  16. <script>
  17. import { provins } from "./data";
  18. class CPickerItem {
  19. data = {
  20. provins: [
  21. "北京市",
  22. "天津市",
  23. "河北省",
  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. defaultIndex: 0,
  54. provinsIndex: 0
  55. }
  56. computed = {}
  57. watch = {}
  58. methods = {
  59. selectchange(e) {
  60. this.provinsIndex = this.defaultIndex = e.detail.index;
  61. }
  62. }
  63. beforeCreate() {}
  64. created() {}
  65. beforeMount() {}
  66. mounted() {}
  67. beforeDestroy() {}
  68. destroyed() {}
  69. }
  70. export default new CPickerItem();
  71. </script>
  72. <style scoped>
  73. .container {
  74. background: #f8f8f8;
  75. }
  76. .page-demo {
  77. background: #fafafa;
  78. }
  79. .title-text {
  80. color: #999;
  81. margin: 30cpx 20cpx 10cpx;
  82. display: block;
  83. font-size: 28cpx;
  84. }
  85. .picker-item {
  86. background: #fff;
  87. border-top: 1px solid #d9d9d9;
  88. border-bottom: 1px solid #d9d9d9;
  89. display: flex;
  90. flex-direction: row;
  91. }
  92. .picker-text-left {
  93. font-size: 40cpx;
  94. height: 70cpx;
  95. line-height: 70cpx;
  96. margin-left: 20cpx;
  97. width: 300cpx;
  98. }
  99. .picker-text-right {
  100. font-size: 40cpx;
  101. height: 70cpx;
  102. line-height: 70cpx;
  103. margin-left: 20cpx;
  104. flex: 1;
  105. text-align: center;
  106. }
  107. .select-text {
  108. font-size: 32cpx;
  109. text-align: center;
  110. display: flex;
  111. justify-content: center;
  112. align-items: center;
  113. }
  114. </style>
  115. <script cml-type="json">
  116. {
  117. "base": {
  118. "usingComponents": {
  119. "c-picker-item": "cml-ui/components/c-picker-item/c-picker-item"
  120. }
  121. }
  122. }
  123. </script>

c-picker-item  - 图1wx

c-picker-item  - 图2web

c-picker-item  - 图3native