data-picker.nvue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="container">
  3. <uni-card is-full :is-shadow="false">
  4. <text class="uni-h6">标签组件多用于商品分类、重点内容显示等场景。</text>
  5. </uni-card>
  6. <!-- <view class="title">
  7. <text>uni-data-picker</text>
  8. </view>
  9. <uni-data-picker placeholder="请选择地址" popup-title="请选择所在地区" :preload="true" :step-searh="true" self-field="code"
  10. parent-field="parent_code" collection="opendb-city-china" orderby="value asc" field="code as value, name as text, eq(['$type', 2]) as isleaf" @nodeclick="onnodeclick" @change="onchange">
  11. </uni-data-picker>
  12. <view class="title">
  13. <text>uni-data-picker 有默认值</text>
  14. </view>
  15. <uni-data-picker placeholder="请选择地址" popup-title="请选择所在地区" :preload="true" :step-searh="true" self-field="code"
  16. parent-field="parent_code" collection="opendb-city-china" orderby="value asc" field="code as value, name as text, eq(['$type', 2]) as isleaf"
  17. v-model="address">
  18. </uni-data-picker> -->
  19. <uni-section title="本地数据" type="line" padding style="height: calc(100vh - 100px);">
  20. <uni-data-picker placeholder="请选择班级" popup-title="请选择所在地区" :localdata="dataTree" v-model="classes"
  21. @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed">
  22. </uni-data-picker>
  23. </uni-section>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. classes: '1-2',
  31. dataTree: [{
  32. text: "一年级",
  33. value: "1-0",
  34. children: [{
  35. text: "1.1班",
  36. value: "1-1"
  37. },
  38. {
  39. text: "1.2班",
  40. value: "1-2"
  41. }]
  42. },
  43. {
  44. text: "二年级",
  45. value: "2-0",
  46. children: [{
  47. text: "2.1班",
  48. value: "2-1"
  49. },
  50. {
  51. text: "2.2班",
  52. value: "2-2"
  53. }]
  54. },
  55. {
  56. text: "三年级",
  57. value: "3-0",
  58. disable: true
  59. }]
  60. }
  61. },
  62. methods: {
  63. onnodeclick(e) {
  64. console.log(e);
  65. },
  66. onpopupopened(e) {
  67. console.log('popupopened');
  68. },
  69. onpopupclosed(e) {
  70. console.log('popupclosed');
  71. },
  72. onchange(e) {}
  73. }
  74. }
  75. </script>
  76. <style>
  77. .title {
  78. font-size: 14px;
  79. font-weight: bold;
  80. margin: 20px 0 5px 0;
  81. }
  82. .data-pickerview {
  83. height: 400px;
  84. border: 1px #e5e5e5 solid;
  85. }
  86. .popper__arrow {
  87. top: -6px;
  88. left: 50%;
  89. margin-right: 3px;
  90. border-top-width: 0;
  91. border-bottom-color: #EBEEF5;
  92. }
  93. .popper__arrow {
  94. top: -6px;
  95. left: 50%;
  96. margin-right: 3px;
  97. border-top-width: 0;
  98. border-bottom-color: #EBEEF5;
  99. }
  100. </style>