国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uni-app根據(jù)騰訊地圖接口三級(jí)聯(lián)動(dòng)組件

這篇具有很好參考價(jià)值的文章主要介紹了uni-app根據(jù)騰訊地圖接口三級(jí)聯(lián)動(dòng)組件。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

有時(shí)候很懵逼,因?yàn)樾枰玫津v訊地圖接口的三級(jí)聯(lián)動(dòng),習(xí)慣問問度娘,結(jié)果出來了我?guī)啄昵坝肑Q寫的,好吧,還是自己擼一個(gè)現(xiàn)在用的吧

組件使用得是uni-popup彈窗,picker-view 滑動(dòng)選擇地址

訪問騰訊地圖接口使用的是?vue-jsonp?

npm install vue-jsonp

在main.js引入

import {
?? ?VueJsonp
} from 'vue-jsonp'
Vue.use(VueJsonp)

組件address.vue

組件只需要填寫你自己得騰訊地圖的?key就可以了

<template>
	<view class="page-body">
		<uni-popup ref="selectPopup" type="bottom">
			<view class="popupBox">
				<view class="btnBox lwbox flex-around">
					<view class="cancel" @click="close">
						取消
					</view>
					<view class="submit" @click="submit">
						確定
					</view>
				</view>
				<view class="lwbox ">
					<view class="rcon">
						<picker-view :indicator-style="indicatorStyle" :value="provinceValue"
							@change="bindProvinceChange" class="picker-view">
							<picker-view-column>
								<view class="item" v-for="(item,index) in provinceData" :key="index">{{item.fullname}}
								</view>
							</picker-view-column>
						</picker-view>
					</view>
					<view class="rcon">
						<picker-view :indicator-style="indicatorStyle" :value="cityValue" @change="bindCityChange"
							class="picker-view">
							<picker-view-column>
								<view class="item" v-for="(item,index) in cityData" :key="index">{{item.fullname}}</view>
							</picker-view-column>
						</picker-view>
					</view>
					<view class="rcon">
						<picker-view :indicator-style="indicatorStyle" :value="districtValue"
							@change="bindDistrictChange" class="picker-view">
							<picker-view-column>
								<view class="item" v-for="(item,index) in districtData" :key="index">{{item.fullname}}
								</view>
							</picker-view-column>
						</picker-view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapMutations,
		mapActions
	} from "vuex";
	export default {
		components: {},
		data() {
			return {
				key:"***************",//騰訊地圖得key
				
				provinceData: [],
				cityData: [],
				districtData: [],

				provinceValue: [0],
				cityValue: [0],
				districtValue: [0],

				indicatorStyle: `height: 50px;`
			};
		},
		methods: {
			bindProvinceChange(v) {
				let id = this.provinceData[v.detail.value[0]].id
				this.cityData = []
				this.districtData = []
				this.provinceValue = v.detail.value
				this.cityValue = [0]
				this.districtValue = [0]
				this._getAddress(id, 'city')
			},
			bindCityChange(v) {
				let id = this.cityData[v.detail.value[0]].id
				this.cityValue = v.detail.value
				this.districtValue = [0]
				this.districtData = []
				this._getAddress(id, 'district')
			},
			bindDistrictChange(v) {
				this.districtValue = v.detail.value
			},
			open() {
				if (this.provinceData.length == 0) {
					this._getAddress()
				}
				this.$refs.selectPopup.open()
			},
			_getAddress(id, type) {
				let url =
					`https://apis.map.qq.com/ws/district/v1/list?key=${this.key}&output=jsonp`
				if (id) {
					url =
						`https://apis.map.qq.com/ws/district/v1/getchildren?id=${id}&key=${this.key}&output=jsonp`
				}
				this.$jsonp(url).then(data => {
					if (!data.status) {
						if (id) {
							if (type == 'city') {
								this.cityData = data.result[0]
								this._getAddress(this.cityData[0].id, 'district')
							}
							if (type == 'district') {
								this.districtData = data.result[0]
								console.log("this.districtData", this.districtData)
							}

						} else {
							this.provinceData = data.result[0]
							console.log("this.provinceData", this.provinceData)
							this._getAddress(this.provinceData[0].id, 'city')
						}
					}
				})
			},
			close() {
				this.$refs.selectPopup.close()
			},
			submit() {
				let province = this.provinceData[this.provinceValue[0]].fullname,
					city = this.cityData[this.cityValue[0]].fullname,
					district = this.districtData[this.districtValue[0]].fullname
				let addressData = {
					province,
					city,
					district,
					address: province + city + district
				}
				this.$emit('submitAddress', addressData)
				this.close()
			}
		},
		onReachBottom() {
			//上拉觸底
		},
		onPullDownRefresh() {
			//監(jiān)聽用戶下拉動(dòng)作
		},
		onUnload() {}
	};
</script>

<style lang="scss" scoped>
	.popupBox {
		width: 100%;
		background: #fff;
		.btnBox {
			background: #eee;
			.cancel {
				padding: 20rpx;
			}
			.submit {
				padding: 20rpx;
				color: $red;
			}
		}
		.picker-view {
			height: 50vh;
			text-align: center;
			.item {
				line-height: 50px
			}
		}
	}
</style>

使用方法,直接引入組件使用文章來源地址http://www.zghlxwxcb.cn/news/detail-809693.html

<Address @submitAddress="submitAddress" ref="addressPopup"></Address>


methods: {
    selectAddress() {
		this.$refs.addressPopup.open()
	},
	submitAddress(data) {
		this.addressData= data;
	},
}

到了這里,關(guān)于uni-app根據(jù)騰訊地圖接口三級(jí)聯(lián)動(dòng)組件的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • uni-app微信小程序結(jié)合騰訊地圖獲取定位導(dǎo)航以及城市選擇器

    uni-app微信小程序結(jié)合騰訊地圖獲取定位導(dǎo)航以及城市選擇器

    目錄 第一步:登錄小程序公眾平臺(tái)==設(shè)置==第三方設(shè)置 ?第二步:登錄騰訊地圖申請(qǐng)屬于自己小程序的key ?第三步:找到騰訊地圖的插件??????? ?第四步:添加插件與允許授權(quán) ?第五步:使用 ? ?騰訊地圖后臺(tái):https://lbs.qq.com/dev/console/application/mine ? ?添加key,授權(quán)使

    2023年04月12日
    瀏覽(107)
  • uni-app —— 小程序?qū)崿F(xiàn)左右菜單聯(lián)動(dòng)

    uni-app —— 小程序?qū)崿F(xiàn)左右菜單聯(lián)動(dòng)

    文章目錄 前言 一、示意圖 二、使用步驟 1.靜態(tài)頁面的布局 2.模擬數(shù)據(jù)格式 3.左側(cè)菜單的點(diǎn)擊效果 4.右側(cè)菜單的聯(lián)動(dòng)效果 三、具體實(shí)現(xiàn)代碼 1.頁面結(jié)構(gòu) 2.相關(guān)樣式 3.業(yè)務(wù)邏輯部分 今天寫出了一個(gè)新的小玩意兒,個(gè)人認(rèn)為實(shí)現(xiàn)思路與方法還算值得學(xué)習(xí),在這里分享給大家! 頁

    2024年02月07日
    瀏覽(102)
  • uni-app引入地圖map組件--APP開發(fā)

    uni-app引入地圖map組件--APP開發(fā)

    需求場(chǎng)景:使用uni-app地圖組件,實(shí)現(xiàn)APP開發(fā) 開發(fā)環(huán)境:Mac,HbuildX3.4.14 測(cè)試環(huán)境:iOS真機(jī)調(diào)試 一、流程 1、關(guān)于Uini-app的map組件:官方文檔說明。map組件是原生組件,目前只針對(duì)原生APP開發(fā),因此通過app-nvue實(shí)現(xiàn),同時(shí)選擇的地圖服務(wù)商只能是高德地圖。 2、創(chuàng)建高德地圖應(yīng)用

    2024年02月15日
    瀏覽(22)
  • 記錄--Uni-app接入騰訊人臉核身

    記錄--Uni-app接入騰訊人臉核身

    人臉核身功能有多種接入方式,其中包含微信H5、微信小程序、APP、獨(dú)立H5、PC端、API接入6種方式。 ? 我們的產(chǎn)品是使用uni-app來開發(fā),所以第一時(shí)間考慮使用H5方式接入,但是通過與官方技術(shù)人員對(duì)接后得知,uni-app是有原生插件可以用的,所以可以使用app的方式接入,原生的

    2024年02月19日
    瀏覽(96)
  • 【App端】uni-app使用百度地圖api和echarts省市地圖下鉆

    【App端】uni-app使用百度地圖api和echarts省市地圖下鉆

    近期的app項(xiàng)目中想加一個(gè)功能,展示全國各地的某一數(shù)據(jù)統(tǒng)計(jì)情況,想來想去,用echarts做地圖數(shù)據(jù)可視化直觀且美觀。于是就去研究了如何使用,其實(shí)在移動(dòng)端使用echarts地圖踩的bug挺多的,總結(jié)如下。 JavaScript API GL賬號(hào)和獲取密鑰 1、獲取SHA1:Android平臺(tái)云端打包 - 公共測(cè)試

    2024年02月11日
    瀏覽(92)
  • 【App端】uni-app使用echarts和百度地圖api

    【App端】uni-app使用echarts和百度地圖api

    近期的app項(xiàng)目中想加一個(gè)功能,展示全國各地的某一數(shù)據(jù)統(tǒng)計(jì)情況,想來想去,用echarts做地圖數(shù)據(jù)可視化直觀且美觀。于是就去研究了如何使用,其實(shí)在移動(dòng)端使用echarts地圖踩的bug挺多的,總結(jié)如下。 JavaScript API GL賬號(hào)和獲取密鑰 1、獲取SHA1:Android平臺(tái)云端打包 - 公共測(cè)試

    2024年02月11日
    瀏覽(88)
  • Uni-app 小程序使用騰訊云IM實(shí)時(shí)通訊

    Uni-app 小程序使用騰訊云IM實(shí)時(shí)通訊

    // IM 小程序 SDK npm install tim-wx-sdk --save // 發(fā)送圖片、文件等消息需要的 COS SDK? 如果不需要發(fā)送圖片等文件不需要下載 在APP.vue中配置好你的騰訊云配置 我測(cè)試了一下如果直接引入:import TIM from \\\'tim-wx-sdk\\\'的話在添加好友的地方會(huì)有錯(cuò)誤 所以我找到了這種引入方式 :import TIM

    2024年02月15日
    瀏覽(100)
  • uni-app微信小程序打開第三方地圖

    uni-app微信小程序打開第三方地圖

    小程序中有個(gè)按鈕點(diǎn)擊以后會(huì)調(diào)用手機(jī)中第三方地圖進(jìn)行導(dǎo)航。 參數(shù) 位置信息 經(jīng)度 與緯度。 原本以為一切順利,結(jié)果在微信開發(fā)者工具中顯示如下: location參數(shù)格式錯(cuò)誤,請(qǐng)正確填寫 經(jīng)過測(cè)試發(fā)現(xiàn),因?yàn)槲以谖⑿判〕绦蛑惺褂茫阅J(rèn)會(huì)使用騰訊地圖來顯示。 而我的經(jīng)

    2024年02月06日
    瀏覽(104)
  • uni-app動(dòng)態(tài)tabBar,根據(jù)不同用戶展示不同的tabBar

    uni-app動(dòng)態(tài)tabBar,根據(jù)不同用戶展示不同的tabBar

    因?yàn)槲覀冇玫氖莡ni-app框架開發(fā),所以在創(chuàng)建項(xiàng)目的時(shí)候直接創(chuàng)建uni-ui的項(xiàng)目即可,這個(gè)項(xiàng)目模板中自帶了uni的一些好用的組件和api。 起初我想著這個(gè)效果不難實(shí)現(xiàn),因?yàn)楣俜揭灿衋pi可以直接使用,所以我最開始嘗試就是使用uni的api完成,也就是這個(gè) :uni.setTabBarItem(options) 我

    2024年02月09日
    瀏覽(27)
  • uni-app打包后安卓不顯示地圖及相關(guān)操作詳解

    uni-app打包后安卓不顯示地圖及相關(guān)操作詳解

    新公司最近用uni-app寫app,之前的代碼有很多問題,正好趁著改bug的時(shí)間學(xué)習(xí)下uni-app。 使用uni-app在瀏覽器調(diào)試的時(shí)候,地圖是展示的,但是打包完成后,在app端是空白的。咱第一次寫app,啥也不懂啊不是。 附上一張瀏覽器調(diào)試的截圖: 安卓app上是空白頁,就不附圖了。 因?yàn)?/p>

    2024年02月11日
    瀏覽(111)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包