In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces in detail "how to realize the city selector in the development of WeChat Mini Programs". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to realize the city selector in the development of WeChat Mini Programs" can help you solve your doubts. Let's follow the editor's ideas to learn new knowledge.
City selector is essential in mobile development.
Gif:
Here is only part of the js code:
Var city = require ('.. /.. / utils/city.js'); Page ({data: {searchLetter: [], showLetter: ", winHeight: 0, tHeight: 0, bHeight: 0, startPageY: 0, cityList: [], isShowLetter: false, scrollTop: 0, city:"}, onLoad: function (options) {/ / Lifecycle function-load var searchLetter = city.searchLetter; var cityList = city.cityList () / / console.log (cityInfo); var sysInfo = wx.getSystemInfoSync (); console.log (sysInfo); var winHeight = sysInfo.windowHeight; / / add the letter range value / / 1 to match, more screen height setting the height of child elements var itemH = winHeight / searchLetter.length; var tempObj = []; for (var I = 0; I
< searchLetter.length; i++) { var temp = {}; temp.name = searchLetter[i]; temp.tHeight = i * itemH; temp.bHeight = (i + 1) * itemH; tempObj.push(temp) } this.setData({ winHeight: winHeight, itemH: itemH, searchLetter: tempObj, cityList: cityList }) console.log(this.data.cityInfo); }, onReady: function () { // 生命周期函数--监听页面初次渲染完成 }, onShow: function () { // 生命周期函数--监听页面显示 }, onHide: function () { // 生命周期函数--监听页面隐藏 }, onUnload: function () { // 生命周期函数--监听页面卸载 }, onPullDownRefresh: function () { // 页面相关事件处理函数--监听用户下拉动作 }, onReachBottom: function () { // 页面上拉触底事件的处理函数 }, onShareAppMessage: function () { // 用户点击右上角分享 return { title: 'title', // 分享标题 desc: 'desc', // 分享描述 path: 'path' // 分享路径 } }, searchStart: function (e) { var showLetter = e.currentTarget.dataset.letter; var pageY = e.touches[0].pageY; this.setScrollTop(this, showLetter); this.nowLetter(pageY, this); this.setData({ showLetter: showLetter, startPageY: pageY, isShowLetter: true, }) }, searchMove: function (e) { var pageY = e.touches[0].pageY; var startPageY = this.data.startPageY; var tHeight = this.data.tHeight; var bHeight = this.data.bHeight; var showLetter = 0; console.log(pageY); if (startPageY - pageY >0) {/ / move if up (pageY
< tHeight) { // showLetter=this.mateLetter(pageY,this); this.nowLetter(pageY, this); } } else {//向下移动 if (pageY >BHeight) {/ / showLetter=this.mateLetter (pageY,this); this.nowLetter (pageY,this);}, searchEnd: function (e) {/ / console.log (e); / / var showLetter=e.currentTarget.dataset.letter; var that = this; setTimeout (function () {that.setData ({isShowLetter: false})}, 1000)}, nowLetter: function (pageY, that) {/ / currently selected information var letterData = this.data.searchLetter Var bHeight = 0; var tHeight = 0; var showLetter = ""; for (var I = 0; I < letterData.length; iTunes +) {if (letterdata [I] .tHeight)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.