<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
本文範例為大家分享了微信小程式實現字母索引選單的具體程式碼,供大家參考,具體內容如下
wxml檔案
<view class="container"> <view class="content"> <view class="all-food"> <view class="food">全部食物</view> <scroll-view class="food-scroll" scroll-y="true" scroll-into-view="{{toView}}" scroll-with-animation="true"> <view class="food-list"> <view wx:for="{{foodList}}" wx:key="{{index}}" id="{{'food'+index}}" data-title="{{item.title}}"> <view class="nav-text"> <text>{{item.title}}</text> </view> <view class="show-food"> <text wx:for="{{item.lists}}" wx:key="{{index}}">{{item}}</text> </view> </view> </view> </scroll-view> </view> <view class="search-nav" bindtouchstart="touchStart" bindtouchmove="touchMove" bindtouchend="touchEnd"> <text bindtap="foodScroll" data-index="{{index}}" wx:for="{{searchNav}}" wx:key="{{index}}">{{item}}</text> </view> </view> </view>
js檔案
let foodList = require('../../utils/common'); Page({ /** * 頁面的初始資料 */ data: { foodList:[], toView:'', searchNav:[] }, getFoodList(){ let searchNav = this.data.searchNav for(let i in foodList.foodList){ searchNav.push(foodList.foodList[i].title) } this.setData({ foodList:foodList.foodList, searchNav:searchNav }) }, foodScroll(e){ let index = e.currentTarget.dataset.index; this.setData({ toView:`food${index}` }) }, /** * 生命週期函數--監聽頁面載入 */ onLoad: function (options) { this.getFoodList(); }, /** * 生命週期函數--監聽頁面初次渲染完成 */ onReady: function () { }, /** * 生命週期函數--監聽頁面顯示 */ onShow: function () { }, /** * 生命週期函數--監聽頁面隱藏 */ onHide: function () { }, /** * 生命週期函數--監聽頁面解除安裝 */ onUnload: function () { }, /** * 頁面相關事件處理常式--監聽使用者下拉動作 */ onPullDownRefresh: function () { }, /** * 頁面上拉觸底事件的處理常式 */ onReachBottom: function () { }, /** * 使用者點選右上角分享 */ onShareAppMessage: function () { } })
wxss檔案
/* pages/city/city.wxss */ .container { padding: 0 5rpx; display: flex; justify-content:row; background-color: #fff; } .content{ margin-top: 30rpx; width: 100%; } .food{ font-size: 40rpx; padding-bottom: 10rpx; border-bottom: 1rpx solid #fff; height:30rpx; line-height:30rpx; } .food-scroll { left: 0; position: fixed; height: 100%; width: 720rpx; } .show-food{ display: flex; flex-direction: column; justify-content: left; } .show-food text{ margin-top: 10rpx; margin-bottom: 10rpx; font-size: 32rpx; border-bottom: 1rpx solid silver; } .search-nav{ position: fixed; top: 120rpx; bottom: 5rpx; right: 5rpx; display:flex; flex-direction: column; justify-content: space-around; } .search-nav text{ text-align: center; font-size: 24rpx; }
common.js檔案
let food = [ { "title":"A", "lists":[ "艾蒿" ] }, { "title":"B", "lists":["白蘿蔔","白瓜","白菜","菠菜","白筍","百合","擯榔","白花菜","白沙蒿","百里香","豆腐柴","芭蕉","菠蘿","白金瓜" ] }, { "title":"C", "lists":["蠶豆","菜花","春筍","慈菇","刺兒菜","草菇","草莓","橙","茶腸","草魚","鯧魚" ] }, { "title":"D", "lists":["豆腐","豆漿","豆腐腦","豆奶","豆汁","豆腐絲","豆腐卷","豆腐皮","豆腐乾","豆乾尖","豆沙","刀豆","豆角","冬瓜","大蒜","大蔥","大白菜","冬寒菜","冬筍","豆瓣菜","大薯","大車前","地膚","大黃","大麻","大紅菇","地衣","蛋清腸" ] }, { "title":"E", "lists":["鵝肉","鵝肝","鵝腿","鵝蛋"] }, { "title":"F", "lists":["粉絲","腐竹","番茄","方瓜","佛手瓜","分蔥","髮菜" ] }, { "title":"G", "lists":["掛麵","甘薯","甘藍","觀達菜","枸杞","柑","桂圓","橄欖","桂魚","鮭魚"] }, { "title":"H", "lists":["花捲","黃豆","花豆","紅蘿蔔","花葉蘿蔔","胡蘿蔔","荷蘭豆","黃豆芽","葫子","葫蘆","葫蘆條","黃瓜","茴香","黑筍","花案菜","槐花","黃麻葉","苦苦菜","猴頭菇","黃菇","海帶","海棠","黃皮果","火腿腸","火雞","火雞肝","火雞腿","黃油","黃鱔","鰉魚","黃骨魚" ] }, { "title":"J", "lists":["豇豆","芥菜頭","節瓜","金瓜","金絲瓜","韭菜","韭黃","韭苔","金針菜","菊筍","茭白","姜","蕨菜","金針菇","雞肉","雞腿","雞心","雞翅","雞腎","雞脖"] }, { "title":"K", "lists":["空鍋餅","苦瓜","苦菜","口蘑","葵花籽"] }, { "title":"L", "lists":["烙餅","綠豆餅","龍豆","綠豆芽","辣椒","蘿蔔纓","落葵","輪葉黨蔘","羅勒","梨","梅","荔枝","栗子","臘肉","驢肉","驢鞭","驢心","駱駝肉","駱駝掌","駱駝蹄", ] }, { "title":"M", "lists":["麵條","饅頭","木薯","梅豆","木豆","毛豆","毛筍","馬蹄","馬齒莧","馬蘭頭","麥瓶草", "蘑菇","木耳","面蛋","芒果","木瓜","馬肉","馬心" ] }, { "title":"N", "lists":["腦豆","奶茄子","南瓜","牛至","檸檬","牛肉","牛肋","牛腿","牛裡脊","牛蹄筋", "牛鞭","牛肚","牛肝","牛肺","牛腦","牛骨","牛大腸","牛心","牛腎","牛肉乾", "牛肉鬆", ] }, { "title":"O", "lists":["藕粉","藕"] }, { "title":"P", "lists":["扁豆","蒲菜","噴瓜","蒲公英","蘋果","葡萄","葡萄乾"] }, { "title":"Q", "lists":["蕎麥","青豆","茄子","秋葵","青蒜","芹菜","掐不齊","清明菜","球莖茴香","啟明菜葉","青菇" ] }, { "title":"R", "lists":["人蔘果","肉鬆","兒童腸"] }, { "title":"S", "lists":["燒餅","水面筋","馬鈴薯","素火腿","素大腸","素雞","素雞絲卷","素什錦","四季豆","蛇瓜","絲瓜","筍瓜","蒜苗","生菜","水芹菜","山藥","石頭菜","沙蔘葉","鬆菇","沙果","酸刺","石榴","柿子","柿餅","桑葚" ] }, { "title":"T", "lists":["通心麵","甜椒","甜菜葉","茼蒿","湯菜","土三七","苔菜","桃","甜瓜","兔肉" ] }, { "title":"W", "lists":["豌豆","烏菜","萵筍","歪頭菜","梧桐子","無花果","午餐肉" ] }, { "title":"X", "lists":["小豆粥","西葫蘆","小蔥","小白菜","西蘭花","香菜","莧菜","夏枯草","香椿","香茅","小旋花","竹葉菜","香菇","香蕉","西瓜","杏仁","橡子","叉燒肉","鹹肉","香腸" ] }, { "title":"Y", "lists":["油餅","油條","油麵筋","薏米","玉米","芸豆","洋蔥","油菜","芋頭","洋姜","野蔥","野韭菜","營野菊口","野蒜","野莧菜","榆錢","魚腥草","羊肚菌","銀耳","櫻桃","柚","楊梅" ] }, { "title":"Z", "lists":["竹筍"," 榛子","珍珠白菇","紫菜","棗","豬肉","芝麻","豬大排","豬耳","豬蹄","豬頭","豬肘","豬肺","豬肝","豬腦","豬皮","豬舌","豬腰","豬心","豬血" ] } ] module.exports = { foodList:food }
目錄檔案
效果
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援it145.com。
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45