Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 5 dienas
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. # next-indexed-xlist适用于uni-app项目的通讯录、城市、地址索引列表组件
  2. ### 本组件目前兼容微信小程序、H5 app
  3. ### 本组件是通讯录、城市、地址索引列表组件,自带搜索功能,可自定义显示字段,用于通讯录列表、城市列表、地址列表等
  4. > 遇到问题或有建议可以加入QQ群(<font color=#f00>455948571</font>)反馈;
  5. > 如果觉得组件不错,<font color=#f00>给五星鼓励鼓励</font>咯;
  6. >
  7. > 本插件居于npmjs开源包[js-pinyin](https://www.npmjs.com/package/js-pinyin) 进行开发,详细插件功能可以到npm上进行查看;
  8. ### 如果有使用问题请加群
  9. 注意:如果插件问题,请务必给一个完整的复现demo,谢谢配合;
  10. [点击链接加入群聊前端开发(uniapp插件)】](https://qm.qq.com/q/S1bJzQfJAG)
  11. ### 使用示例
  12. ``` html
  13. <template>
  14. <view class="page-main">
  15. <next-indexed-xlist :dataList="dataList" :showAvatar="true" @itemclick="itemclick">
  16. <!--这是默认插槽,额外添加部分-->
  17. <!-- <view class="content-block">
  18. <view class="title"><text>历史记录:</text></view>
  19. <view class="btn"><text>朝阳区</text></view>
  20. <view class="btn"><text>东城区</text></view>
  21. <view class="btn"><text>海淀区</text></view>
  22. </view> -->
  23. <!--自定义name插槽-->
  24. <!-- <template #name="{data: item}">
  25. <view><text>测试name</text></view>
  26. </template> -->
  27. <!--自定义phone插槽-->
  28. <!-- <template #phone="{data: item}">
  29. <view><text>测试phone</text></view>
  30. </template> -->
  31. </next-indexed-xlist>
  32. </view>
  33. </template>
  34. ```
  35. ### vue3使用
  36. ``` ts
  37. <script setup lang="ts">
  38. import { ref } from "vue";
  39. // 通讯录数据形式
  40. const dataList = ref([{
  41. id: '1',
  42. name: '刘**',
  43. phone: '181****5576',
  44. img: 'https://img1.baidu.com/it/u=1016138010,1907110459&fm=253&fmt=auto&app=138&f=JPEG?w=300&h=300'
  45. }, {
  46. id: '2',
  47. name: '王**',
  48. phone: '181****5576',
  49. img: 'https://img1.baidu.com/it/u=1016138010,1907110459&fm=253&fmt=auto&app=138&f=JPEG?w=300&h=300'
  50. }, {
  51. id: '3',
  52. name: '黎**',
  53. phone: '181****5576',
  54. img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  55. }, {
  56. id: '4',
  57. name: '王**',
  58. phone: '181****5576',
  59. img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  60. }, {
  61. id: '5',
  62. name: '马**',
  63. phone: '181****5576',
  64. img: 'https://c-ssl.dtstatic.com/uploads/item/202005/17/20200517225139_Awrwa.thumb.1000_0.jpeg'
  65. }, {
  66. id: '6',
  67. name: '韩**',
  68. phone: '181****5576',
  69. img: 'https://c-ssl.dtstatic.com/uploads/item/202005/17/20200517225139_Awrwa.thumb.1000_0.jpeg'
  70. }, {
  71. id: '7',
  72. name: '张**',
  73. phone: '181****5576',
  74. img: 'https://img0.baidu.com/it/u=2337762009,1252339875&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  75. }, {
  76. id: '8',
  77. name: '杨**',
  78. phone: '181****5576',
  79. img: 'https://img0.baidu.com/it/u=2337762009,1252339875&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  80. }, {
  81. id: '9',
  82. name: '张**',
  83. phone: '18198045576',
  84. img: 'https://img2.baidu.com/it/u=2638426337,2608406797&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  85. }, {
  86. id: '10',
  87. name: '李**',
  88. phone: '181****1176',
  89. img: 'https://img2.baidu.com/it/u=2638426337,2608406797&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  90. }, {
  91. id: '11',
  92. name: '陈**',
  93. phone: '153****5576',
  94. img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201412%2F25%2F20141225133106_zjyfa.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1687677419&t=3464ddbfcb8ad0291ed5f38374f23869'
  95. }, {
  96. id: '12',
  97. name: '李**',
  98. phone: '131****5576',
  99. img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201412%2F25%2F20141225133106_zjyfa.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1687677419&t=3464ddbfcb8ad0291ed5f38374f23869'
  100. }, {
  101. id: '13',
  102. name: '唐**',
  103. phone: '181****3476',
  104. img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201412%2F25%2F20141225133106_zjyfa.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1687677419&t=3464ddbfcb8ad0291ed5f38374f23869'
  105. }, {
  106. id: '14',
  107. name: '刘**',
  108. phone: '181****5576',
  109. img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  110. }, {
  111. id: '15',
  112. name: '秦**',
  113. phone: '181****5576',
  114. img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  115. }, {
  116. id: '16',
  117. name: '朱**',
  118. phone: '181****5576',
  119. img: 'https://c-ssl.dtstatic.com/uploads/item/202005/17/20200517225139_Awrwa.thumb.1000_0.jpeg'
  120. }])
  121. // 地址数据形式
  122. // const dataList = ref([{
  123. // "id": 6,
  124. // "code": "110101000000",
  125. // "name": "东城区",
  126. // "parentCode": "110100000000",
  127. // "level": 3,
  128. // "abbr": "DC",
  129. // "deleted": 0
  130. // }, {
  131. // "id": 10,
  132. // "code": "110105000000",
  133. // "name": "朝阳区",
  134. // "parentCode": "110100000000",
  135. // "level": 3,
  136. // "abbr": "CY",
  137. // "deleted": 0
  138. // }, {
  139. // "id": 13,
  140. // "code": "110106000000",
  141. // "name": "丰台区",
  142. // "parentCode": "110100000000",
  143. // "level": 3,
  144. // "abbr": "FT",
  145. // "deleted": 0
  146. // }, {
  147. // "id": 14,
  148. // "code": "110107000000",
  149. // "name": "石景山区",
  150. // "parentCode": "110100000000",
  151. // "level": 3,
  152. // "abbr": "SJS",
  153. // "deleted": 0
  154. // }, {
  155. // "id": 15,
  156. // "code": "110108000000",
  157. // "name": "海淀区",
  158. // "parentCode": "110100000000",
  159. // "level": 3,
  160. // "abbr": "HD",
  161. // "deleted": 0
  162. // }, {
  163. // "id": 16,
  164. // "code": "110109000000",
  165. // "name": "门头沟区",
  166. // "parentCode": "110100000000",
  167. // "level": 3,
  168. // "abbr": "MTG",
  169. // "deleted": 0
  170. // }, {
  171. // "id": 19,
  172. // "code": "110111000000",
  173. // "name": "房山区",
  174. // "parentCode": "110100000000",
  175. // "level": 3,
  176. // "abbr": "FS",
  177. // "deleted": 0
  178. // }, {
  179. // "id": 20,
  180. // "code": "110112000000",
  181. // "name": "通州区",
  182. // "parentCode": "110100000000",
  183. // "level": 3,
  184. // "abbr": "TZ",
  185. // "deleted": 0
  186. // }, {
  187. // "id": 21,
  188. // "code": "110113000000",
  189. // "name": "顺义区",
  190. // "parentCode": "110100000000",
  191. // "level": 3,
  192. // "abbr": "SY",
  193. // "deleted": 0
  194. // }, {
  195. // "id": 22,
  196. // "code": "110114000000",
  197. // "name": "昌平区",
  198. // "parentCode": "110100000000",
  199. // "level": 3,
  200. // "abbr": "CP",
  201. // "deleted": 0
  202. // }, {
  203. // "id": 23,
  204. // "code": "110115000000",
  205. // "name": "大兴区",
  206. // "parentCode": "110100000000",
  207. // "level": 3,
  208. // "abbr": "DX",
  209. // "deleted": 0
  210. // }, {
  211. // "id": 25,
  212. // "code": "110116000000",
  213. // "name": "怀柔区",
  214. // "parentCode": "110100000000",
  215. // "level": 3,
  216. // "abbr": "HR",
  217. // "deleted": 0
  218. // }, {
  219. // "id": 26,
  220. // "code": "110117000000",
  221. // "name": "平谷区",
  222. // "parentCode": "110100000000",
  223. // "level": 3,
  224. // "abbr": "PG",
  225. // "deleted": 0
  226. // }, {
  227. // "id": 27,
  228. // "code": "110118000000",
  229. // "name": "密云区",
  230. // "parentCode": "110100000000",
  231. // "level": 3,
  232. // "abbr": "MY",
  233. // "deleted": 0
  234. // }, {
  235. // "id": 28,
  236. // "code": "110119000000",
  237. // "name": "延庆区",
  238. // "parentCode": "110100000000",
  239. // "level": 3,
  240. // "abbr": "YQ",
  241. // "deleted": 0
  242. // }])
  243. function itemclick(e) {
  244. console.log('点击列表回调:', e)
  245. }
  246. </script>
  247. <style lang="scss">
  248. .content-block {
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: flex-start;
  252. background-color: #fff;
  253. .title {
  254. color: #333;
  255. padding: 20rpx;
  256. margin-right: 20rpx;
  257. display: flex;
  258. flex-direction: column;
  259. justify-content: center;
  260. }
  261. .btn {
  262. color: #ccc;
  263. padding: 10rpx;
  264. border: 1rpx solid #ccc;
  265. border-radius: 10rpx;
  266. margin: 20rpx 10rpx;
  267. font-size: 28rpx;
  268. display: flex;
  269. flex-direction: column;
  270. justify-content: center;
  271. }
  272. }
  273. </style>
  274. ```
  275. ### vue2使用
  276. ``` ts
  277. export default {
  278. data () {
  279. return {
  280. dataList: [{
  281. id: '1',
  282. name: '刘**',
  283. phone: '181****5576',
  284. img: 'https://img1.baidu.com/it/u=1016138010,1907110459&fm=253&fmt=auto&app=138&f=JPEG?w=300&h=300'
  285. }, {
  286. id: '2',
  287. name: '王**',
  288. phone: '181****5576',
  289. img: 'https://img1.baidu.com/it/u=1016138010,1907110459&fm=253&fmt=auto&app=138&f=JPEG?w=300&h=300'
  290. }, {
  291. id: '3',
  292. name: '黎**',
  293. phone: '181****5576',
  294. img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  295. }, {
  296. id: '4',
  297. name: '王**',
  298. phone: '181****5576',
  299. img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  300. }]
  301. }
  302. },
  303. methods: {
  304. itemclick(e) {
  305. console.log('点击列表回调:', e)
  306. }
  307. }
  308. }
  309. ```
  310. ### 属性说明
  311. | 名称 | 类型 | 默认值 | 描述 |
  312. | ----------------------------|--------------- | ---------------------- | ----------------------|
  313. | dataList | Array | [] | 数据源 |
  314. | idKey | String | id | 显示的主键key值 |
  315. | nameKey | String | name | 显示的名字key值 |
  316. | phoneKey | String | phone | 显示的电话key值 |
  317. | imgKey | String | img | 显示的头像key值 |
  318. | radius | Number | 4rpx | 头像圆角(rpx、px、%) |
  319. | showAvatar | Boolean | true | 是否显示头像 |
  320. | isInterlock | Boolean | false | 是否双向联动 |
  321. ## Event 事件
  322. |事件名 |说明 |类型 |回调参数 |
  323. |---- |---- |---- |---- |
  324. |itemclick|菜单项item点击事件 |emit |Object |
  325. ### 微信小程序在线体验
  326. ![](https://lixueshiaa.github.io/webtest/www/static/img/ponder_next.png)
  327. ### 预览
  328. ***
  329. | (通信录演示效果) | (地区选择演示效果) |
  330. | :-----------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
  331. | ![](https://lixueshiaa.github.io/webtest/www/static/next-indexed-list-a.gif) | ![](https://lixueshiaa.github.io/webtest/www/static/next-indexed-list-b.gif) |