linkage.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <view class="item" @tap="linkageVisible=true">自定义多级联动</view>
  4. <view class="result">选择结果:{{result.result}}</view>
  5. <w-picker
  6. :visible.sync="linkageVisible"
  7. mode="linkage"
  8. :value="defaultRegion1"
  9. :options="options"
  10. :level="4"
  11. default-type="id"
  12. :default-props="defaultProps1"
  13. @confirm="onConfirm($event,'linkage')"
  14. @cancel="onCancel"
  15. ref="linkage"
  16. ></w-picker>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. linkageVisible:false,
  24. result:{
  25. result:""
  26. },
  27. defaultProps1:{
  28. label:"name",
  29. value:"id",
  30. children:"child"
  31. },
  32. defaultRegion1:["120000","120100","120101","12010102"],
  33. options:[
  34. {
  35. id: '110000',
  36. name: '北京市',
  37. child: [{
  38. id: "110100",
  39. name: "北京市",
  40. child: [{
  41. id: "110101",
  42. name: "东城区",
  43. child:[{
  44. id: "11010101",
  45. name: "小区1",
  46. },{
  47. id: "11010102",
  48. name: "小区2",
  49. }]
  50. }, {
  51. id: "110102",
  52. name: "西城区"
  53. },{
  54. id: "110105",
  55. name: "朝阳区"
  56. }, {
  57. id: "110106",
  58. name: "丰台区"
  59. }, {
  60. id: "110107",
  61. name: "石景山区"
  62. }, {
  63. id: "110108",
  64. name: "海淀区"
  65. }, {
  66. id: "110109",
  67. name: "门头沟区"
  68. }, {
  69. id: "110111",
  70. name: "房山区"
  71. }, {
  72. id: "110112",
  73. name: "通州区"
  74. }, {
  75. id: "110113",
  76. name: "顺义区"
  77. }, {
  78. id: "110114",
  79. name: "昌平区"
  80. }, {
  81. id: "110115",
  82. name: "大兴区"
  83. }, {
  84. id: "110116",
  85. name: "怀柔区"
  86. }, {
  87. id: "110117",
  88. name: "平谷区"
  89. }, {
  90. id: "110118",
  91. name: "密云区"
  92. }, {
  93. id: "110119",
  94. name: "延庆区"
  95. }]
  96. }]
  97. }, {
  98. id: '120000',
  99. name: '天津市',
  100. child: [{
  101. id: "120100",
  102. name: "天津市",
  103. child: [{
  104. id: "120101",
  105. name: "和平区",
  106. child:[{
  107. id: "12010101",
  108. name: "小区3",
  109. },{
  110. id: "12010102",
  111. name: "小区4",
  112. }]
  113. }, {
  114. id: "120102",
  115. name: "河东区"
  116. }, {
  117. id: "120103",
  118. name: "河西区"
  119. }, {
  120. id: "120104",
  121. name: "南开区"
  122. }, {
  123. id: "120105",
  124. name: "河北区"
  125. }, {
  126. id: "120106",
  127. name: "红桥区"
  128. }, {
  129. id: "120110",
  130. name: "东丽区"
  131. }, {
  132. id: "120111",
  133. name: "西青区"
  134. }, {
  135. id: "120112",
  136. name: "津南区"
  137. }, {
  138. id: "120113",
  139. name: "北辰区"
  140. }, {
  141. id: "120114",
  142. name: "武清区"
  143. }, {
  144. id: "120115",
  145. name: "宝坻区"
  146. }, {
  147. id: "120116",
  148. name: "滨海新区"
  149. }, {
  150. id: "120117",
  151. name: "宁河区"
  152. }, {
  153. id: "120118",
  154. name: "静海区"
  155. }, {
  156. id: "120119",
  157. name: "蓟州区"
  158. }]
  159. }]
  160. }
  161. ]
  162. };
  163. },
  164. methods:{
  165. onConfirm(res){
  166. this.result=res;
  167. console.log(res)
  168. },
  169. onCancel(){
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. </style>