查看个人博客

之前都是后端操作的,城市数据都是存在数据库的,前端选择然后去后端查的,比较简单方便。这次开发的是前端,客户没有提供城市选择的接口,省市这些数据感觉还是放在数据库后端操作较好。

数据和方法也是参考了别人博客的代码,直接贴代码

1

2

3

4

5

6

7

8

9

10

11

<!--页面调用组件-->

<atom-city ref="resetCountry"></atom-city>

 

   

/*写在页面加载方法中,重置选择框中的值*/

this.$refs.resetCountry.reset();

 

/*写在提交方法中,从组件中获取选择的值*/

var country = that.$refs.resetCountry.changeValueCountry()

var province = that.$refs.resetCountry.changeValueProv()

var city = that.$refs.resetCountry.changeValueCity()

 

因为有多个页面需要使用,所以把选择城市的封装成atom-city组件,我这个需求是有选择国家的,如果选择的是中国才会有省份城市的选择框,否则用户自己输入省份城市,以下代码参考https://blog.csdn.net/lllo3o/article/details/72955701

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

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

<template>

  <div>

    <div class="form-group">

      <label>{{$t('account.countryAdd')}}</label>

      <div class="input-group height-fix-6">

          <div class="input-group-prepend"><span class="input-group-text">#</span></div>

          <select class="form-control" v-model="selectCountry" v-on:change="getCount($event)">

              <option value="" selected>{{$t('message.pleaseEnter')}}</option>

              <option v-for="item in countrys" :label="item.label" :value="item.value">{{item.value}}</option>

          </select>

      </div>

    </div>

    <div class="form-group">

        <div v-if="selectCountry=='中国'">

          <label>{{$t('account.provinceAdd')}}</label>

          <div class="input-group height-fix-6">

            <div class="input-group-prepend"><span class="input-group-text">#</span></div>

          <select class="form-control" v-model="selectProv" v-on:change="getProv($event)">

            <option value="" selected>{{$t('message.pleaseEnter')}}</option>

              <option v-for="item in provs" :label="item.label" :value="item.value">{{item.value}}</option>

          </select>

        </div>

        <div v-if="selectProv!=''">

          <label>{{$t('account.cityAdd')}}</label>

          <div class="input-group height-fix-6">

            <div class="input-group-prepend"><span class="input-group-text">#</span></div>

            <select class="form-control" v-model="selectCity" v-on:change="getCity($event)">

               <option value="" selected>{{$t('message.pleaseEnter')}}</option>

                <option v-for="item in citys" :label="item.label" :value="item.value">{{item.value}} </option>

            </select>

          </div>

        </div>

      </div>

      <div v-if="selectCountry!='中国' && selectCountry!=''" >

          <label>{{$t('account.provinceAdd')}}</label>

          <div class="input-group height-fix-6">

            <div class="input-group-prepend"><span class="input-group-text">#</span></div>

            <input type="text" v-model="selectProv" class="form-control" :placeholder="$i18n.t('message.pleaseEnter')">

          </div>

          <label>{{$t('account.cityAdd')}}</label>

          <div class="input-group height-fix-6">

            <div class="input-group-prepend"><span class="input-group-text">#</span></div>

            <input type="text" v-model="selectCity" class="form-control" :placeholder="$i18n.t('message.pleaseEnter')">

          </div>

      </div>

 

    </div>

  </div>

</template>

 

<script>

export default {

  name: 'atom-city',

  data(){

    return{

      countrys:[{label:"中国",value:"中国"},

                {label:"日本",value:"日本"},

                {label:"美国",value:"美国"},

                {label:"韩国",value:"韩国"},

                {label:"印度",value:"印度"}

      ],

      provs:[{label:"北京市",value:"北京市"},

            {label:"天津市",value:"天津市"},

            {label:"河北省",value:"河北省"},

            {label:"山西省",value:"山西省"},

            {label:"内蒙古自治区",value:"内蒙古自治区"},

            {label:"辽宁省",value:"辽宁省"},

            {label:"吉林省",value:"吉林省"},

            {label:"黑龙江省",value:"黑龙江省"},

            {label:"上海市",value:"上海市"},

            {label:"江苏省",value:"江苏省"},

            {label:"浙江省",value:"浙江省"},

            {label:"安徽省",value:"安徽省"},

            {label:"福建省",value:"福建省"},

            {label:"江西省",value:"江西省"},

            {label:"山东省",value:"山东省"},

            {label:"河南省",value:"河南省"},

            {label:"湖北省",value:"湖北省"},

            {label:"湖南省",value:"湖南省"},

            {label:"广东省",value:"广东省"},

            {label:"广西壮族自治区",value:"广西壮族自治区"},

            {label:"海南省",value:"海南省"},

            {label:"重庆市",value:"重庆市"},

            {label:"四川省",value:"四川省"},

            {label:"贵州省",value:"贵州省"},

            {label:"云南省",value:"云南省"},

            {label:"西藏自治区",value:"西藏自治区"},

            {label:"陕西省",value:"陕西省"},

            {label:"甘肃省",value:"甘肃省"},

            {label:"青海省",value:"青海省"},

            {label:"宁夏回族自治区",value:"宁夏回族自治区"},

            {label:"新疆维吾尔自治区",value:"新疆维吾尔自治区"},

            {label:"台湾省",value:"台湾省"},

            {label:"香港特别行政区",value:"香港特别行政区"},

            {label:"澳门特别行政区",value:"澳门特别行政区"}] ,

                citys: [],

                selectProv: '',

                selectCity: '',

                selectCountry:''

    }

  },

  methods: {

    /*二级联动选择地区*/

            getProv: function (prov) {

                let tempCity=[];             

                this.citys=[];

                this.selectCity='';               

                let allCity=[{

                    prov: "北京市",

                    label: "北京市"

                }, {

                    prov: "天津市",

                    label: "天津市"

                }, {

                    prov: "河北省",

                    label: "石家庄市"

                }, {

                    prov: "河北省",

                    label: "唐山市"

                }, {

                    prov: "河北省",

                    label: "秦皇岛市"

                }, {

                    prov: "河北省",

                    label: "邯郸市"

                }, {

                    prov: "河北省",

                    label: "邢台市"

                }, {

                    prov: "河北省",

                    label: "保定市"

                }, {

                    prov: "河北省",

                    label: "张家口市"

                }, {

                    prov: "河北省",

                    label: "承德市"

                }, {

                    prov: "河北省",

                    label: "沧州市"

                }, {

                    prov: "河北省",

                    label: "廊坊市"

                }, {

                    prov: "河北省",

                    label: "衡水市"

                }, {

                    prov: "山西省",

                    label: "太原市"

                }, {

                    prov: "山西省",

                    label: "大同市"

                }, {

                    prov: "山西省",

                    label: "阳泉市"

                }, {

                    prov: "山西省",

                    label: "长治市"

                }, {

                    prov: "山西省",

                    label: "晋城市"

                }, {

                    prov: "山西省",

                    label: "朔州市"

                }, {

                    prov: "山西省",

                    label: "晋中市"

                }, {

                    prov: "山西省",

                    label: "运城市"

                }, {

                    prov: "山西省",

                    label: "忻州市"

                }, {

                    prov: "山西省",

                    label: "临汾市"

                }, {

                    prov: "山西省",

                    label: "吕梁市"

                }, {

                    prov: "内蒙古自治区",

                    label: "呼和浩特市"

                }, {

                    prov: "内蒙古自治区",

                    label: "包头市"

                }, {

                    prov: "内蒙古自治区",

                    label: "乌海市"

                }, {

                    prov: "内蒙古自治区",

                    label: "赤峰市"

                }, {

                    prov: "内蒙古自治区",

                    label: "通辽市"

                }, {

                    prov: "内蒙古自治区",

                    label: "鄂尔多斯市"

                }, {

                    prov: "内蒙古自治区",

                    label: "呼伦贝尔市"

                }, {

                    prov: "内蒙古自治区",

                    label: "巴彦淖尔市"

                }, {

                    prov: "内蒙古自治区",

                    label: "乌兰察布市"

                }, {

                    prov: "内蒙古自治区",

                    label: "兴安盟"

                }, {

                    prov: "内蒙古自治区",

                    label: "锡林郭勒盟"

                }, {

                    prov: "内蒙古自治区",

                    label: "阿拉善盟"

                }, {

                    prov: "辽宁省",

                    label: "沈阳市"

                }, {

                    prov: "辽宁省",

                    label: "大连市"

                }, {

                    prov: "辽宁省",

                    label: "鞍山市"

                }, {

                    prov: "辽宁省",

                    label: "抚顺市"

                }, {

                    prov: "辽宁省",

                    label: "本溪市"

                }, {

                    prov: "辽宁省",

                    label: "丹东市"

                }, {

                    prov: "辽宁省",

                    label: "锦州市"

                }, {

                    prov: "辽宁省",

                    label: "营口市"

                }, {

                    prov: "辽宁省",

                    label: "阜新市"

                }, {

                    prov: "辽宁省",

                    label: "辽阳市"

                }, {

                    prov: "辽宁省",

                    label: "盘锦市"

                }, {

                    prov: "辽宁省",

                    label: "铁岭市"

                }, {

                    prov: "辽宁省",

                    label: "朝阳市"

                }, {

                    prov: "辽宁省",

                    label: "葫芦岛市"

                }, {

                    prov: "吉林省",

                    label: "长春市"

                }, {

                    prov: "吉林省",

                    label: "吉林市"

                }, {

                    prov: "吉林省",

                    label: "四平市"

                }, {

                    prov: "吉林省",

                    label: "辽源市"

                }, {

                    prov: "吉林省",

                    label: "通化市"

                }, {

                    prov: "吉林省",

                    label: "白山市"

                }, {

                    prov: "吉林省",

                    label: "松原市"

                }, {

                    prov: "吉林省",

                    label: "白城市"

                }, {

                    prov: "吉林省",

                    label: "延边朝鲜族自治州"

                }, {

                    prov: "黑龙江省",

                    label: "哈尔滨市"

                }, {

                    prov: "黑龙江省",

                    label: "齐齐哈尔市"

                }, {

                    prov: "黑龙江省",

                    label: "鸡西市"

                }, {

                    prov: "黑龙江省",

                    label: "鹤岗市"

                }, {

                    prov: "黑龙江省",

                    label: "双鸭山市"

                }, {

                    prov: "黑龙江省",

                    label: "大庆市"

                }, {

                    prov: "黑龙江省",

                    label: "伊春市"

                }, {

                    prov: "黑龙江省",

                    label: "佳木斯市"

                }, {

                    prov: "黑龙江省",

                    label: "七台河市"

                }, {

                    prov: "黑龙江省",

                    label: "牡丹江市"

                }, {

                    prov: "黑龙江省",

                    label: "黑河市"

                }, {

                    prov: "黑龙江省",

                    label: "绥化市"

                }, {

                    prov: "黑龙江省",

                    label: "大兴安岭地区"

                }, {

                    prov: "上海市",

                    label: "上海市"

                }, {

                    prov: "江苏省",

                    label: "南京市"

                }, {

                    prov: "江苏省",

                    label: "无锡市"

                }, {

                    prov: "江苏省",

                    label: "徐州市"

                }, {

                    prov: "江苏省",

                    label: "常州市"

                }, {

                    prov: "江苏省",

                    label: "苏州市"

                }, {

                    prov: "江苏省",

                    label: "南通市"

                }, {

                    prov: "江苏省",

                    label: "连云港市"

                }, {

                    prov: "江苏省",

                    label: "淮安市"

                }, {

                    prov: "江苏省",

                    label: "盐城市"

                }, {

                    prov: "江苏省",

                    label: "扬州市"

                }, {

                    prov: "江苏省",

                    label: "镇江市"

                }, {

                    prov: "江苏省",

                    label: "泰州市"

                }, {

                    prov: "江苏省",

                    label: "宿迁市"

                }, {

                    prov: "浙江省",

                    label: "杭州市"

                }, {

                    prov: "浙江省",

                    label: "宁波市"

                }, {

                    prov: "浙江省",

                    label: "温州市"

                }, {

                    prov: "浙江省",

                    label: "嘉兴市"

                }, {

                    prov: "浙江省",

                    label: "湖州市"

                }, {

                    prov: "浙江省",

                    label: "绍兴市"

                }, {

                    prov: "浙江省",

                    label: "金华市"

                }, {

                    prov: "浙江省",

                    label: "衢州市"

                }, {

                    prov: "浙江省",

                    label: "舟山市"

                }, {

                    prov: "浙江省",

                    label: "台州市"

                }, {

                    prov: "浙江省",

                    label: "丽水市"

                }, {

                    prov: "安徽省",

                    label: "合肥市"

                }, {

                    prov: "安徽省",

                    label: "芜湖市"

                }, {

                    prov: "安徽省",

                    label: "蚌埠市"

                }, {

                    prov: "安徽省",

                    label: "淮南市"

                }, {

                    prov: "安徽省",

                    label: "马鞍山市"

                }, {

                    prov: "安徽省",

                    label: "淮北市"

                }, {

                    prov: "安徽省",

                    label: "铜陵市"

                }, {

                    prov: "安徽省",

                    label: "安庆市"

                }, {

                    prov: "安徽省",

                    label: "黄山市"

                }, {

                    prov: "安徽省",

                    label: "滁州市"

                }, {

                    prov: "安徽省",

                    label: "阜阳市"

                }, {

                    prov: "安徽省",

                    label: "宿州市"

                }, {

                    prov: "安徽省",

                    label: "六安市"

                }, {

                    prov: "安徽省",

                    label: "亳州市"

                }, {

                    prov: "安徽省",

                    label: "池州市"

                }, {

                    prov: "安徽省",

                    label: "宣城市"

                }, {

                    prov: "福建省",

                    label: "福州市"

                }, {

                    prov: "福建省",

                    label: "厦门市"

                }, {

                    prov: "福建省",

                    label: "莆田市"

                }, {

                    prov: "福建省",

                    label: "三明市"

                }, {

                    prov: "福建省",

                    label: "泉州市"

                }, {

                    prov: "福建省",

                    label: "漳州市"

                }, {

                    prov: "福建省",

                    label: "南平市"

                }, {

                    prov: "福建省",

                    label: "龙岩市"

                }, {

                    prov: "福建省",

                    label: "宁德市"

                }, {

                    prov: "江西省",

                    label: "南昌市"

                }, {

                    prov: "江西省",

                    label: "景德镇市"

                }, {

                    prov: "江西省",

                    label: "萍乡市"

                }, {

                    prov: "江西省",

                    label: "九江市"

                }, {

                    prov: "江西省",

                    label: "新余市"

                }, {

                    prov: "江西省",

                    label: "鹰潭市"

                }, {

                    prov: "江西省",

                    label: "赣州市"

                }, {

                    prov: "江西省",

                    label: "吉安市"

                }, {

                    prov: "江西省",

                    label: "宜春市"

                }, {

                    prov: "江西省",

                    label: "抚州市"

                }, {

                    prov: "江西省",

                    label: "上饶市"

                }, {

                    prov: "山东省",

                    label: "济南市"

                }, {

                    prov: "山东省",

                    label: "青岛市"

                }, {

                    prov: "山东省",

                    label: "淄博市"

                }, {

                    prov: "山东省",

                    label: "枣庄市"

                }, {

                    prov: "山东省",

                    label: "东营市"

                }, {

                    prov: "山东省",

                    label: "烟台市"

                }, {

                    prov: "山东省",

                    label: "潍坊市"

                }, {

                    prov: "山东省",

                    label: "济宁市"

                }, {

                    prov: "山东省",

                    label: "泰安市"

                }, {

                    prov: "山东省",

                    label: "威海市"

                }, {

                    prov: "山东省",

                    label: "日照市"

                }, {

                    prov: "山东省",

                    label: "莱芜市"

                }, {

                    prov: "山东省",

                    label: "临沂市"

                }, {

                    prov: "山东省",

                    label: "德州市"

                }, {

                    prov: "山东省",

                    label: "聊城市"

                }, {

                    prov: "山东省",

                    label: "滨州市"

                }, {

                    prov: "山东省",

                    label: "菏泽市"

                }, {

                    prov: "河南省",

                    label: "郑州市"

                }, {

                    prov: "河南省",

                    label: "开封市"

                }, {

                    prov: "河南省",

                    label: "洛阳市"

                }, {

                    prov: "河南省",

                    label: "平顶山市"

                }, {

                    prov: "河南省",

                    label: "安阳市"

                }, {

                    prov: "河南省",

                    label: "鹤壁市"

                }, {

                    prov: "河南省",

                    label: "新乡市"

                }, {

                    prov: "河南省",

                    label: "焦作市"

                }, {

                    prov: "河南省",

                    label: "濮阳市"

                }, {

                    prov: "河南省",

                    label: "许昌市"

                }, {

                    prov: "河南省",

                    label: "漯河市"

                }, {

                    prov: "河南省",

                    label: "三门峡市"

                }, {

                    prov: "河南省",

                    label: "南阳市"

                }, {

                    prov: "河南省",

                    label: "商丘市"

                }, {

                    prov: "河南省",

                    label: "信阳市"

                }, {

                    prov: "河南省",

                    label: "周口市"

                }, {

                    prov: "河南省",

                    label: "驻马店市"

                }, {

                    prov: "河南省",

                    label: "省直辖县级行政区划"

                }, {

                    prov: "湖北省",

                    label: "武汉市"

                }, {

                    prov: "湖北省",

                    label: "黄石市"

                }, {

                    prov: "湖北省",

                    label: "十堰市"

                }, {

                    prov: "湖北省",

                    label: "宜昌市"

                }, {

                    prov: "湖北省",

                    label: "襄阳市"

                }, {

                    prov: "湖北省",

                    label: "鄂州市"

                }, {

                    prov: "湖北省",

                    label: "荆门市"

                }, {

                    prov: "湖北省",

                    label: "孝感市"

                }, {

                    prov: "湖北省",

                    label: "荆州市"

                }, {

                    prov: "湖北省",

                    label: "黄冈市"

                }, {

                    prov: "湖北省",

                    label: "咸宁市"

                }, {

                    prov: "湖北省",

                    label: "随州市"

                }, {

                    prov: "湖北省",

                    label: "恩施土家族苗族自治州"

                }, {

                    prov: "湖北省",

                    label: "省直辖县级行政区划"

                }, {

                    prov: "湖北省",

                    label: "仙桃市"

                }, {

                    prov: "湖北省",

                    label: "潜江市"

                }, {

                    prov: "湖北省",

                    label: "天门市"

                }, {

                    prov: "湖北省",

                    label: "神农架林区"

                }, {

                    prov: "湖南省",

                    label: "长沙市"

                }, {

                    prov: "湖南省",

                    label: "株洲市"

                }, {

                    prov: "湖南省",

                    label: "湘潭市"

                }, {

                    prov: "湖南省",

                    label: "衡阳市"

                }, {

                    prov: "湖南省",

                    label: "邵阳市"

                }, {

                    prov: "湖南省",

                    label: "岳阳市"

                }, {

                    prov: "湖南省",

                    label: "常德市"

                }, {

                    prov: "湖南省",

                    label: "张家界市"

                }, {

                    prov: "湖南省",

                    label: "益阳市"

                }, {

                    prov: "湖南省",

                    label: "郴州市"

                }, {

                    prov: "湖南省",

                    label: "永州市"

                }, {

                    prov: "湖南省",

                    label: "怀化市"

                }, {

                    prov: "湖南省",

                    label: "娄底市"

                }, {

                    prov: "湖南省",

                    label: "湘西土家族苗族自治州"

                }, {

                    prov: "广东省",

                    label: "广州市"

                }, {

                    prov: "广东省",

                    label: "韶关市"

                }, {

                    prov: "广东省",

                    label: "深圳市"

                }, {

                    prov: "广东省",

                    label: "珠海市"

                }, {

                    prov: "广东省",

                    label: "汕头市"

                }, {

                    prov: "广东省",

                    label: "佛山市"

                }, {

                    prov: "广东省",

                    label: "江门市"

                }, {

                    prov: "广东省",

                    label: "湛江市"

                }, {

                    prov: "广东省",

                    label: "茂名市"

                }, {

                    prov: "广东省",

                    label: "肇庆市"

                }, {

                    prov: "广东省",

                    label: "惠州市"

                }, {

                    prov: "广东省",

                    label: "梅州市"

                }, {

                    prov: "广东省",

                    label: "汕尾市"

                }, {

                    prov: "广东省",

                    label: "河源市"

                }, {

                    prov: "广东省",

                    label: "阳江市"

                }, {

                    prov: "广东省",

                    label: "清远市"

                }, {

                    prov: "广东省",

                    label: "东莞市"

                }, {

                    prov: "广东省",

                    label: "中山市"

                }, {

                    prov: "广东省",

                    label: "潮州市"

                }, {

                    prov: "广东省",

                    label: "揭阳市"

                }, {

                    prov: "广东省",

                    label: "云浮市"

                }, {

                    prov: "广西壮族自治区",

                    label: "南宁市"

                }, {

                    prov: "广西壮族自治区",

                    label: "柳州市"

                }, {

                    prov: "广西壮族自治区",

                    label: "桂林市"

                }, {

                    prov: "广西壮族自治区",

                    label: "梧州市"

                }, {

                    prov: "广西壮族自治区",

                    label: "北海市"

                }, {

                    prov: "广西壮族自治区",

                    label: "防城港市"

                }, {

                    prov: "广西壮族自治区",

                    label: "钦州市"

                }, {

                    prov: "广西壮族自治区",

                    label: "贵港市"

                }, {

                    prov: "广西壮族自治区",

                    label: "玉林市"

                }, {

                    prov: "广西壮族自治区",

                    label: "百色市"

                }, {

                    prov: "广西壮族自治区",

                    label: "贺州市"

                }, {

                    prov: "广西壮族自治区",

                    label: "河池市"

                }, {

                    prov: "广西壮族自治区",

                    label: "来宾市"

                }, {

                    prov: "广西壮族自治区",

                    label: "崇左市"

                }, {

                    prov: "海南省",

                    label: "海口市"

                }, {

                    prov: "海南省",

                    label: "三亚市"

                }, {

                    prov: "海南省",

                    label: "三沙市"

                }, {

                    prov: "海南省",

                    label: "省直辖县级行政区划"

                }, {

                    prov: "海南省",

                    label: "五指山市"

                }, {

                    prov: "海南省",

                    label: "琼海市"

                }, {

                    prov: "海南省",

                    label: "儋州市"

                }, {

                    prov: "海南省",

                    label: "文昌市"

                }, {

                    prov: "海南省",

                    label: "万宁市"

                }, {

                    prov: "海南省",

                    label: "东方市"

                }, {

                    prov: "海南省",

                    label: "定安县"

                }, {

                    prov: "海南省",

                    label: "屯昌县"

                }, {

                    prov: "海南省",

                    label: "澄迈县"

                }, {

                    prov: "海南省",

                    label: "临高县"

                }, {

                    prov: "海南省",

                    label: "白沙黎族自治县"

                }, {

                    prov: "海南省",

                    label: "昌江黎族自治县"

                }, {

                    prov: "海南省",

                    label: "乐东黎族自治县"

                }, {

                    prov: "海南省",

                    label: "陵水黎族自治县"

                }, {

                    prov: "海南省",

                    label: "保亭黎族苗族自治县"

                }, {

                    prov: "海南省",

                    label: "琼中黎族苗族自治县"

                }, {

                    prov: "重庆市",

                    label: "重庆市"

                }, {

                    prov: "四川省",

                    label: "成都市"

                }, {

                    prov: "四川省",

                    label: "自贡市"

                }, {

                    prov: "四川省",

                    label: "攀枝花市"

                }, {

                    prov: "四川省",

                    label: "泸州市"

                }, {

                    prov: "四川省",

                    label: "德阳市"

                }, {

                    prov: "四川省",

                    label: "绵阳市"

                }, {

                    prov: "四川省",

                    label: "广元市"

                }, {

                    prov: "四川省",

                    label: "遂宁市"

                }, {

                    prov: "四川省",

                    label: "内江市"

                }, {

                    prov: "四川省",

                    label: "乐山市"

                }, {

                    prov: "四川省",

                    label: "南充市"

                }, {

                    prov: "四川省",

                    label: "眉山市"

                }, {

                    prov: "四川省",

                    label: "宜宾市"

                }, {

                    prov: "四川省",

                    label: "广安市"

                }, {

                    prov: "四川省",

                    label: "达州市"

                }, {

                    prov: "四川省",

                    label: "雅安市"

                }, {

                    prov: "四川省",

                    label: "巴中市"

                }, {

                    prov: "四川省",

                    label: "资阳市"

                }, {

                    prov: "四川省",

                    label: "阿坝藏族羌族自治州"

                }, {

                    prov: "四川省",

                    label: "甘孜藏族自治州"

                }, {

                    prov: "四川省",

                    label: "凉山彝族自治州"

                }, {

                    prov: "贵州省",

                    label: "贵阳市"

                }, {

                    prov: "贵州省",

                    label: "六盘水市"

                }, {

                    prov: "贵州省",

                    label: "遵义市"

                }, {

                    prov: "贵州省",

                    label: "安顺市"

                }, {

                    prov: "贵州省",

                    label: "毕节市"

                }, {

                    prov: "贵州省",

                    label: "铜仁市"

                }, {

                    prov: "贵州省",

                    label: "黔西南布依族苗族自治州"

                }, {

                    prov: "贵州省",

                    label: "黔东南苗族侗族自治州"

                }, {

                    prov: "贵州省",

                    label: "黔南布依族苗族自治州"

                }, {

                    prov: "云南省",

                    label: "昆明市"

                }, {

                    prov: "云南省",

                    label: "曲靖市"

                }, {

                    prov: "云南省",

                    label: "玉溪市"

                }, {

                    prov: "云南省",

                    label: "保山市"

                }, {

                    prov: "云南省",

                    label: "昭通市"

                }, {

                    prov: "云南省",

                    label: "丽江市"

                }, {

                    prov: "云南省",

                    label: "普洱市"

                }, {

                    prov: "云南省",

                    label: "临沧市"

                }, {

                    prov: "云南省",

                    label: "楚雄彝族自治州"

                }, {

                    prov: "云南省",

                    label: "红河哈尼族彝族自治州"

                }, {

                    prov: "云南省",

                    label: "文山壮族苗族自治州"

                }, {

                    prov: "云南省",

                    label: "西双版纳傣族自治州"

                }, {

                    prov: "云南省",

                    label: "大理白族自治州"

                }, {

                    prov: "云南省",

                    label: "德宏傣族景颇族自治州"

                }, {

                    prov: "云南省",

                    label: "怒江傈僳族自治州"

                }, {

                    prov: "云南省",

                    label: "迪庆藏族自治州"

                }, {

                    prov: "西藏自治区",

                    label: "拉萨市"

                }, {

                    prov: "西藏自治区",

                    label: "昌都地区"

                }, {

                    prov: "西藏自治区",

                    label: "山南地区"

                }, {

                    prov: "西藏自治区",

                    label: "日喀则地区"

                }, {

                    prov: "西藏自治区",

                    label: "那曲地区"

                }, {

                    prov: "西藏自治区",

                    label: "阿里地区"

                }, {

                    prov: "西藏自治区",

                    label: "林芝地区"

                }, {

                    prov: "陕西省",

                    label: "西安市"

                }, {

                    prov: "陕西省",

                    label: "铜川市"

                }, {

                    prov: "陕西省",

                    label: "宝鸡市"

                }, {

                    prov: "陕西省",

                    label: "咸阳市"

                }, {

                    prov: "陕西省",

                    label: "渭南市"

                }, {

                    prov: "陕西省",

                    label: "延安市"

                }, {

                    prov: "陕西省",

                    label: "汉中市"

                }, {

                    prov: "陕西省",

                    label: "榆林市"

                }, {

                    prov: "陕西省",

                    label: "安康市"

                }, {

                    prov: "陕西省",

                    label: "商洛市"

                }, {

                    prov: "甘肃省",

                    label: "兰州市"

                }, {

                    prov: "甘肃省",

                    label: "嘉峪关市"

                }, {

                    prov: "甘肃省",

                    label: "金昌市"

                }, {

                    prov: "甘肃省",

                    label: "白银市"

                }, {

                    prov: "甘肃省",

                    label: "天水市"

                }, {

                    prov: "甘肃省",

                    label: "武威市"

                }, {

                    prov: "甘肃省",

                    label: "张掖市"

                }, {

                    prov: "甘肃省",

                    label: "平凉市"

                }, {

                    prov: "甘肃省",

                    label: "酒泉市"

                }, {

                    prov: "甘肃省",

                    label: "庆阳市"

                }, {

                    prov: "甘肃省",

                    label: "定西市"

                }, {

                    prov: "甘肃省",

                    label: "陇南市"

                }, {

                    prov: "甘肃省",

                    label: "临夏回族自治州"

                }, {

                    prov: "甘肃省",

                    label: "甘南藏族自治州"

                }, {

                    prov: "青海省",

                    label: "西宁市"

                }, {

                    prov: "青海省",

                    label: "海东市"

                }, {

                    prov: "青海省",

                    label: "海北藏族自治州"

                }, {

                    prov: "青海省",

                    label: "黄南藏族自治州"

                }, {

                    prov: "青海省",

                    label: "海南藏族自治州"

                }, {

                    prov: "青海省",

                    label: "果洛藏族自治州"

                }, {

                    prov: "青海省",

                    label: "玉树藏族自治州"

                }, {

                    prov: "青海省",

                    label: "海西蒙古族藏族自治州"

                }, {

                    prov: "宁夏回族自治区",

                    label: "银川市"

                }, {

                    prov: "宁夏回族自治区",

                    label: "石嘴山市"

                }, {

                    prov: "宁夏回族自治区",

                    label: "吴忠市"

                }, {

                    prov: "宁夏回族自治区",

                    label: "固原市"

                }, {

                    prov: "宁夏回族自治区",

                    label: "中卫市"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "乌鲁木齐市"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "克拉玛依市"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "吐鲁番地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "哈密地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "昌吉回族自治州"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "博尔塔拉蒙古自治州"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "巴音郭楞蒙古自治州"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "阿克苏地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "克孜勒苏柯尔克孜自治州"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "喀什地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "和田地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "伊犁哈萨克自治州"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "塔城地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "阿勒泰地区"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "自治区直辖县级行政区划"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "石河子市"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "阿拉尔市"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "图木舒克市"

                }, {

                    prov: "新疆维吾尔自治区",

                    label: "五家渠市"

                }, {

                    prov: "台湾省",

                    label: "台北市"

                }, {

                    prov: "台湾省",

                    label: "高雄市"

                }, {

                    prov: "台湾省",

                    label: "基隆市"

                }, {

                    prov: "台湾省",

                    label: "台中市"

                }, {

                    prov: "台湾省",

                    label: "台南市"

                }, {

                    prov: "台湾省",

                    label: "新竹市"

                }, {

                    prov: "台湾省",

                    label: "嘉义市"

                }, {

                    prov: "台湾省",

                    label: "省直辖"

                }, {

                    prov: "香港特别行政区",

                    label: "香港岛"

                }, {

                    prov: "香港特别行政区",

                    label: "九龙"

                }, {

                    prov: "香港特别行政区",

                    label: "新界"

                }, {

                    prov: "澳门特别行政区",

                    label: "澳门半岛"

                }, {

                    prov: "澳门特别行政区",

                    label: "澳门离岛"

                }, {

                    prov: "澳门特别行政区",

                    label: "无堂区划分区域"

                }];

                for (var val of allCity){

                    if (this.selectProv == val.prov){

                        console.log(val);

                        tempCity.push({label: val.label, value: val.label})

                    }

                }

                this.citys = tempCity;

            },

            getCity: function (city) {

                console.log(city);

                console.log(this.selectCity)

            },

            getCount: function(country) {

              this.selectProv='';

              this.citys=[];

              this.selectCity='';

            },

            reset: function() {

              this.selectProv= '';

              this.selectCity='';

              this.selectCountry='';

            },

            changeValueCountry: function(event){

                return this.selectCountry

            },

            changeValueProv: function(event){

                return this.selectProv

            },

            changeValueCity: function(event){

                return this.selectCity

            }

  }

}

</script>

 

其他方式参考:

vue.js 省份城市联动选择实现示例(通过vue数组过滤)

基于vue2实现省市联动

 

Logo

前往低代码交流专区

更多推荐