小編給大家分享一下小程序組件開發(fā)中省市區(qū)三級(jí)聯(lián)動(dòng)的示例分析,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
站在用戶的角度思考問題,與客戶深入溝通,找到瑪沁網(wǎng)站設(shè)計(jì)與瑪沁網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、虛擬主機(jī)、企業(yè)郵箱。業(yè)務(wù)覆蓋瑪沁地區(qū)。
index.wxml
<import src="../../templates/address-temp"/> <template is="addressPicker" data="{{provinceIndex:city.provinceIndex,cityIndex:city.cityIndex,districtIndex:city.districtIndex,province:city.province, city:city.city[city.selectedProvince],district:city.district[city.selectedCity]}}"/>
index.js
var city = require("../../utils/city.js"); Page({ data: {}, onLoad: function() { console.log('onLoad...'); var that = this; city.init(that); } });
address-temp.wxml
<?xml version="1.0" encoding="utf-8"?> <template name="addressPicker"> <view style="display:flex;margin:0;height:100%;align-items: center;justify-content: center"> <view style="width:100%;"> <picker bindchange="bindProvinceChange" value="{{provinceIndex}}" range="{{province}}"> <view style="text-align:center;padding:10rpx;font-size:0.8rem">{{province[provinceIndex]}}</view> </picker> </view> <view style="width:100%;"> <picker bindchange="bindCityChange" value="{{cityIndex}}" range="{{city}}"> <view style="text-align:center;padding:10rpx;font-size:0.8rem">{{city[cityIndex]}}</view> </picker> </view> <view style="width:100%;"> <picker bindchange="bindDistrictChange" value="{{districtIndex}}" range="{{district}}"> <view style="text-align:center;padding:10rpx;font-size:0.8rem">{{district[districtIndex]}}</view> </picker> </view> </view> </template>
city.js
var city = { province: ['-請(qǐng)選擇-', '福建省'], city: { '-請(qǐng)選擇-': ['-請(qǐng)選擇-'], '福建省': ['福州市', '廈門市', '泉州市'] }, district: { '-請(qǐng)選擇-': ['-請(qǐng)選擇-'], '福州市': ['鼓樓區(qū)', '臺(tái)江區(qū)'], '廈門市': ['湖里區(qū)', '集美區(qū)'], '泉州市': ['晉江市', '安溪縣'] }, provinceIndex: 0, cityIndex: 0, districtIndex: 0, selectedProvince: '-請(qǐng)選擇-', selectedCity: '-請(qǐng)選擇-', selectedDistrct: '-請(qǐng)選擇-' }; function init(that) { that.setData({ 'city': city }); var bindProvinceChange = function(e) { var city = that.data.city; that.setData({ 'city.provinceIndex': e.detail.value, 'city.selectedProvince': city.province[e.detail.value], 'city.selectedCity': city.city[city.province[e.detail.value]][0], 'city.selectedDistrct': city.district[city.city[city.province[e.detail.value]][0]][0], 'city.cityIndex': 0, 'city.districtIndex': 0 }); }; var bindCityChange = function(e) { var city = that.data.city; that.setData({ 'city.cityIndex': e.detail.value, 'city.selectedCity': city.city[city.selectedProvince][e.detail.value], 'city.districtIndex': 0, 'city.selectedDistrct': city.district[city.city[city.selectedProvince][e.detail.value]][0] }); }; var bindDistrictChange = function(e) { var city = that.data.city; that.setData({ 'city.districtIndex': e.detail.value, 'city.selectedDistrct': city.district[city.selectedCity][e.detail.value] }); }; that['bindProvinceChange'] = bindProvinceChange; that['bindCityChange'] = bindCityChange; that['bindDistrictChange'] = bindDistrictChange; } module.exports = { init: init }
看完了這篇文章,相信你對(duì)“小程序組件開發(fā)中省市區(qū)三級(jí)聯(lián)動(dòng)的示例分析”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
網(wǎng)站欄目:小程序組件開發(fā)中省市區(qū)三級(jí)聯(lián)動(dòng)的示例分析
網(wǎng)址分享:http://jinyejixie.com/article8/joooip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、企業(yè)網(wǎng)站制作、網(wǎng)站導(dǎo)航、營銷型網(wǎng)站建設(shè)、網(wǎng)站策劃、App設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)