mip-city-selection 城市选择组件

mip-city-selection 分组选择组件,可用于城市分组,英文名分组,颜色分组等。

标题内容
类型通用
支持布局responsive,fixed-height,fill,container,fixed
所需脚本https://c.mipcdn.com/static/v2/mip-city-selection/mip-city-selection.js

示例

基本用法

1、本地数据

按照如下示例配置城市数据。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!-- <mip-test id="cityTest"></mip-test> 测试组件,模拟接收事件 --> <mip-city-selection class="mip-hidden" on="citySelected"> <!-- <mip-city-selection class="mip-hidden" on="citySelected:cityTest.print" data-src="http://172.24.138.98:8888/xxxxtest.json"> --> <script type="application/json"> { "list": [{ "key": "热门", "cities": [{ "city": "北京", "pinyin": "beijing", "code": "1" }, { "city": "上海", "pinyin": "shanghai", "code": "2" }, { "city": "广州", "pinyin": "guangzhou", "code": "3" }, { "city": "深圳", "pinyin": "shenzhen", "code": "4" }, { "city": "重庆", "pinyin": "chongqing", "code": "5" } ] }, { "key": "A", "cities": [{ "city": "澳门", "pinyin": "aomen", "code": "7" }, { "city": "安庆", "pinyin": "anqing", "code": "8" }, { "city": "安泽", "pinyin": "anze", "code": "9" } ] }, { "key": "B", "cities": [{ "city": "宝清", "pinyin": "baoqing", "code": "10" }, { "city": "宝鸡", "pinyin": "baoji", "code": "11" }, { "city": "巴东", "pinyin": "badong", "code": "12" } ] }, { "key": "C", "cities": [{ "city": "重庆", "pinyin": "chongqing", "code": "13" }, { "city": "成都", "pinyin": "chengdu", "code": "14" }, { "city": "苍山", "pinyin": "cangshan", "code": "15" } ] }, { "key": "D", "cities": [{ "city": "大庆", "pinyin": "daqing", "code": "16" }, { "city": "大理", "pinyin": "dali", "code": "17" }, { "city": "东莞", "pinyin": "dongguan", "code": "18" } ] }, { "key": "E", "cities": [{ "city": "鄂尔多斯", "pinyin": "eerduosi", "code": "19" }, { "city": "峨眉山", "pinyin": "emeishan", "code": "20" } ] }, { "key": "F", "cities": [{ "city": "阜阳", "pinyin": "fuyang", "code": "21" }, { "city": "福州", "pinyin": "fuzhou", "code": "22" }, { "city": "防城港", "pinyin": "fangchenggang", "code": "23" } ] }, { "key": "F", "cities": [{ "city": "阜阳", "pinyin": "fuyang", "code": "21" }, { "city": "福州", "pinyin": "fuzhou", "code": "22" }, { "city": "防城港", "pinyin": "fangchenggang", "code": "23" } ] }, { "key": "F", "cities": [{ "city": "阜阳", "pinyin": "fuyang", "code": "21" }, { "city": "福州", "pinyin": "fuzhou", "code": "22" }, { "city": "防城港", "pinyin": "fangchenggang", "code": "23" } ] }, { "key": "F", "cities": [{ "city": "阜阳", "pinyin": "fuyang", "code": "21" }, { "city": "福州", "pinyin": "fuzhou", "code": "22" }, { "city": "防城港", "pinyin": "fangchenggang", "code": "23" } ] }, { "key": "G", "cities": [{ "city": "广州", "pinyin": "guangzhou", "code": "24" }, { "city": "贵阳", "pinyin": "guiyang", "code": "25" } ] }] } </script> </mip-city-selection>

2、异步传入数据

按照如下示例配置城市数据。

注意:data-src属于前后端交互请求。由于 MIP-Cache 为 HTTPS 环境,data-src 要求支持 HTTPS.

1
2
3
4
<!-- <mip-test id="cityTest"></mip-test> 测试组件,模拟接收事件 --> <mip-city-selection class="mip-hidden" data-src="https://xxx/cities.json" on="citySelected:cityTest.print"> <!--存在 data-src 时,本地数据配置不生效--> </mip-city-selection>

抛出事件

ready

每次触发抛事件后,抛出mip-city-selectioncitySelected事件,并传json数据

格式 如 { "city": "鄂尔多斯", "pinyin": "eerduosi", "code": "19"}

组件间通信请看文档 https://www.mipengine.org/doc/3-widget/6-help/3-mip-normal.html

属性说明

data-src

说明:用于指向远程数据地址,异步加载并渲染。指明data-src后,配置在<script type="application/json">本地的数据不再生效。 使用限制:异步加载数据属于前后端交互请求。由于 MIP-Cache 为 HTTPS 环境,data-src 要求支持 HTTPS.