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

微信小程序--列表展示

這篇具有很好參考價值的文章主要介紹了微信小程序--列表展示。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

小知識:

wx:for="{{list}}"用來循環(huán)數(shù)組。

wx:for-item=‘變量名(隨便起)’ ? 它是指定循環(huán)數(shù)據(jù)當前的變量名,可以通過 ?{{變量名.屬性}} 展示數(shù)組的元素。

wx:for-index=‘變量名(隨便起)’,它是指向當前元素的下標名,可以在其他事件中定義自定義事件(data-xxx='{{變量名}}',,該自定義屬性可以在參數(shù)e下面打印出來)獲取該下標。

?思考:二維甚至多維數(shù)組應該如何遍歷?

例題:?

列表數(shù)據(jù)如圖所示:?

微信小程序列表樣式,微信小程序,微信小程序,前端?

例題采用了scroll-view和swiper組件。代碼如下:

new_canteen.js:

// pages/canteen/new_canteen.js
const app = getApp();
Page({
    /** 頁面的初始數(shù)據(jù)*/
    data: {
        navigationSetting:{
            title:'食堂',
            height: app.globalData.navBarHeight,
            paddingTop: app.globalData.statusBarHeight,
            // backgroundColor:'red',
            size:'default'
        },
        tabList: ['一粟堂', '三清園', '七品居','九華廳'],
        tabNow: 0, //當前選中的tab標簽索引
        search: "",
        tradeList: [['從前說','千千萬萬','千千萬萬','千千萬萬','千千萬萬'],['我記得']], //對應tab顯示的商家列表
        list:[ //搜索后的list內(nèi)容列表
            {Name:"一粟堂",arr:[
              {title: '燒鹵家族', sale: 358, rating: 4.9, consumption: 15},
              {title: '燒鹵家族', sale: 518, rating: 4.9, consumption: 35},
              {title: '燒鹵家族', sale: 138, rating: 4.9, consumption: 23},
            ]},
            {Name:"三清園",arr:[
              {title: '漢味小吃', sale: 156, rating: 4.9, consumption: 25},
              {title: '漢味小吃', sale: 324, rating: 4.9, consumption: 17},
            ]},
            {Name:"七品居",arr:[
                {title: '古茗', sale: 156, rating: 4.9, consumption: 25},
                {title: '古茗', sale: 351, rating: 4.9, consumption: 19},
                {title: '古茗', sale: 324, rating: 4.9, consumption: 17},
            ]},
            {Name:"九華廳",arr:[
                {title: '漢味小吃', sale: 156, rating: 4.9, consumption: 25},
            ]}
        ],
    },
    selectTab (e) { //切換不同的tab
        this.setData({
            tabNow: e.currentTarget.dataset.id
        })
    },
    handleSwiperChange(e) { //對應改變tab
        this.setData({
          tabNow: e.detail.current
        })
    },
    getContent(e) {
        console.log("主頁:",e)
        this.setData({
          search: e.detail
        })
    },

    /**
     * 生命周期函數(shù)--監(jiān)聽頁面加載
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函數(shù)--監(jiān)聽頁面顯示
     */
    onShow: function () {

    },

    /**
     * 生命周期函數(shù)--監(jiān)聽頁面隱藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函數(shù)--監(jiān)聽頁面卸載
     */
    onUnload: function () {

    },

    /**
     * 頁面相關事件處理函數(shù)--監(jiān)聽用戶下拉動作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 頁面上拉觸底事件的處理函數(shù)
     */
    onReachBottom: function () {

    },

    /**
     * 用戶點擊右上角分享
     */
    onShareAppMessage: function () {

    }
})

new_canteen.json:

{
  "usingComponents": {
    "navigation":"../../components/navbar/navbar",
    "search": "/components/search/search"
  },
  "navigationStyle": "custom",
  "navigationBarTextStyle": "black"
}

new_canteen.wxml:

<!--pages/canteen/new_canteen.wxml-->
<navigation defaultSetting="{{navigationSetting}}"></navigation>

<!--pages/list/trade_company.wxml-->
<!-- <view class="head flex-row">
  <view class="head-title">食堂</view>
</view> -->
<scroll-view scroll-y class="container">
    <view class="container-head">
        <!--Tab選項卡-->
        <scroll-view scroll-x class="scroll_view" scroll-with-animation="true" enable-flex="true"> 
            <view class="tab"> 
                <view class="tab_item {{ tabNow === index ? 'select' : '' }}" wx:for="{{ tabList }}" data-id="{{ index }}" wx:key="index" bindtap="selectTab"> {{ item }} 
                </view> 
            </view>
        </scroll-view>
    </view>
    <search bind:Searchcontent="getContent" ></search>
    <!--下方內(nèi)容顯示-->
    <swiper class="container-swiper" current="{{tabNow}}" bindchange="handleSwiperChange">
        <swiper-item wx:for="{{list}}" wx:key="index" >
            <scroll-view class='container-swiper-sc' enable-flex="true">
                <view class="mendian-list" style="width: 94%; margin-left: 3%;">
                    <block wx:for="{{ list[tabNow].arr }}" wx:for-item="map">
                        <navigator class="mendian-info" url="../canteen/detail">
                            <image class="thumb" src="../../img/大活.png" pb="100"></image>
                            <div class="mendian-text">
                                <div class="title">{{map.title}}</div>
                                <view class="qisong-juli flex-between" style="font-size: small;">
                                    <image src="../../img/ratingstar.png" mode="aspectFit" style="width: 15px;height: 15px;"></image>
                                    <text style="margin-left: 5px; color: red; background-color: pink;">{{map.rating}}</text>
                                    <text style="margin-left: 15px;">月售:{{map.sale}}</text>
                                    <view>人均消費:{{map.consumption}}元/人</view>
                                </view>
                            </div>
                        </navigator>
                    </block>
                </view>

            </scroll-view>
        </swiper-item>
    </swiper>
    
</scroll-view>

new_canteen.wxss:

/* pages/canteen/new_canteen.wxss */
page {
    height: 100%;/*頁面高度為屏幕的高度*/
}
.head {
  position: fixed;
    height: 13%; 
    width: 100%;
    color: #333;
    font-size: 30rpx;
    font-weight: bold;
    padding-bottom: 10rpx;
    box-sizing: border-box;
}
.head-title {
    position: relative;
    display: inline-block;
    height: 100%;
}
.head-title::after {
    content: '';
    position: absolute;
    z-index: 99;
    width: 15px;
    height: 15px;
    margin-left: -15rpx;
    border-top: 3px solid #333;
    border-right: 3px solid #333;
    border-top-right-radius: 100%;
    transform: rotate(-225deg);
    left: 50%;
    bottom: 3px;
}
.container {
    width: 100%;
    background-color: #fff;
    overflow: hidden;
    /* border-radius: 30rpx 30rpx 0 0; */
    padding: 0 0;
}
.container-head {
    width: 100%;
    box-sizing: border-box;
  }
.scroll_view {
    height: 80rpx;
    border-radius: 50rpx;
    /* background-color: #eeece4; */
    white-space: nowrap;/*不換行*/
  }
  
.scroll_view .tab {
    /* padding: 0 10rpx; */
    line-height: 65rpx;
    display: inline-block;
    text-align: center;
    height: 80rpx;
    vertical-align: top;/*防止高度塌陷*/
}
/*激活當前tab樣式*/
.scroll_view .select {
    /* color: #1067D1; */
    font-size: larger;
    font-weight: bold;
    border-bottom: 18px solid #F6CB48;
} 
.tab .tab_item {
    height: 70rpx;
    display: inline-block;
    line-height: 90rpx;
    margin: 0 26rpx;
    padding: 0 20rpx;
    flex: 1;
}
.container-swiper {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-flow: column;
}
.container-swiper-sc {
    height: 100%;
}
.container-swiper-sc .items {
    padding: 0 2%;
    width: 100%;
    box-sizing: border-box;
  }
  .container-swiper-sc .items .item-img {
    width: 30vw;
    height: 30vw;
    margin-right: 2.8%;
    margin-bottom: 10rpx;
    flex-shrink: 0;
  }
  .container-swiper-sc .items .item-img:nth-child(3n+3) {
    margin-right: 0;
  }

/* 商家列表展示 */
/*列表展示*/
.mendian-list .mendian-info {
  display: flex;
  padding: 8px;
  margin-top: 16rpx;
  border-radius: 20px;
  /* border-bottom: 1px #dedede dashed; */
  border: 2px solid #A9A9A9;
  /* background-color: #D7EEFC; */
}
.mendian-list .mendian-info:last-child {
  /* border-bottom: none; */
  margin-bottom: 3px;
}
.mendian-list .thumb {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
  margin-right: 15px;
  border-radius: 10px;
  background-color: blue;
}
.mendian-list .mendian-text {
  flex-grow: 1;
  flex-shrink: 1;
  display: flex;
  justify-content: space-between;
  flex-flow: column;
}
.mendian-list .title {
  font-size: 18px;
  font-weight: 600;
  /* text-align: center; */
  color: #484848;
  margin-top: 5px;
}

小圖片:

微信小程序列表樣式,微信小程序,微信小程序,前端

實現(xiàn)效果:?

效果展示

?文章來源地址http://www.zghlxwxcb.cn/news/detail-613433.html

到了這里,關于微信小程序--列表展示的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

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

領支付寶紅包贊助服務器費用

相關文章

  • 第二章Python序列-列表

    第二章Python序列-列表

    (1)直接將一個列表對象賦給變量 (2)用list()將其他類型轉(zhuǎn)化為列表 雙向索引 (1)訪問:通過索引 (2)通過for語句 修改 (1)運算符 +(合并列表,生成一個新列表) +=(合并列表,原地操作) * (列表元素重復) (2)append()方法 語法:append(object) (3)指定位置添加 insert

    2023年04月11日
    瀏覽(63)
  • 【python進階】列表排序已經(jīng)掌握?這種將變量插入列表序列的方法你該知道了

    【python進階】列表排序已經(jīng)掌握?這種將變量插入列表序列的方法你該知道了

    ???♂?作者簡介:生魚同學,大數(shù)據(jù)科學與技術專業(yè)碩士在讀?????,曾獲得華為杯數(shù)學建模國家二等獎??,MathorCup 數(shù)學建模競賽國家二等獎??,亞太數(shù)學建模國家二等獎??。 ??研究方向:復雜網(wǎng)絡科學 ??興趣方向:利用python進行數(shù)據(jù)分析與機器學習,數(shù)學建模競

    2023年04月08日
    瀏覽(19)
  • python經(jīng)典有序序列的list列表推導式

    生成一個數(shù)據(jù)列表 使用列表推導式生成該數(shù)據(jù)列表 分析: 1、使用一行代碼的列表推導式就完成了該列表的生成 2、[i for i in range(20)],第一個i元素代表向列表list_2中添加的元素 3、[i for i in range(20)],第二個i元素代表for循環(huán)遍歷的i元素 使用列表推導式生成只有偶數(shù)的數(shù)據(jù)列

    2024年02月02日
    瀏覽(23)
  • 黑馬微信小程序-實現(xiàn)本地服務九宮格并展示商品列表

    黑馬微信小程序-實現(xiàn)本地服務九宮格并展示商品列表

    1.1準備接口 黑馬接口:https://applet-base-api-t.itheima.net/categories 說明:這是獲取九宮格的數(shù)據(jù)接口 1.2使用接口 ?說明:聲明變量獲取數(shù)據(jù)。 ?res.data數(shù)據(jù) 編寫簡單css 實圖展示? ? ? 聲明query變量? 并設置導航標題 標題展示? ? ? 2.1準備接口 商品列表接口:https://applet-base-api-t

    2024年02月11日
    瀏覽(20)
  • 【Python 筆記(二)——基本語句 變量類型 字符串 序列 列表與元組 字典與集合】

    在 Python 中,基本語句可以幫助我們完成一些基本的操作,如控制流程、定義函數(shù)等。以下是 Python 中的幾種基本語句: if 語句 if 語句用于判斷某個條件是否成立,如果條件成立則執(zhí)行相應的代碼塊。 for 語句 for 語句用于遍歷序列中的元素,依次執(zhí)行相應的代碼塊。 while 語

    2024年02月08日
    瀏覽(29)
  • 【微信小程序】一文搞懂條件渲染、列表渲染以及wxss模板樣式

    【微信小程序】一文搞懂條件渲染、列表渲染以及wxss模板樣式

    ??作者簡介:蘇涼(專注于網(wǎng)絡爬蟲,數(shù)據(jù)分析,正在學習前端的路上) ??博客主頁:蘇涼.py的博客 ??系列專欄:小程序開發(fā)基礎教程 ??名言警句:海闊憑魚躍,天高任鳥飛。 ??要是覺得博主文章寫的不錯的話,還望大家三連支持一下呀?。。???關注?點贊??收藏??

    2024年01月16日
    瀏覽(26)
  • 微信小程序 | 小程序開發(fā)

    微信小程序 | 小程序開發(fā)

    ??? 微信小程序?qū)冢盒〕绦蜷_發(fā) 初級知識 ????? 個人簡介:一個不甘平庸的平凡人?? ? 個人主頁:CoderHing的個人主頁 ?? 格言: ?? 路漫漫其修遠兮,吾將上下而求索?? ?? 你的一鍵三連是我更新的最大動力?? 目錄 一、認識小程序開發(fā) 什么是小程序? 各個平臺小

    2024年01月24日
    瀏覽(61)
  • 水球展示——微信小程序

    水球展示——微信小程序

    html? ?less js 獲取數(shù)據(jù)賦值就行 ?

    2024年02月07日
    瀏覽(19)
  • 微信小程序開發(fā)之微信小程序交互

    微信小程序開發(fā)之微信小程序交互

    目錄 一、小程序交互 前端: 1、先在登陸界面中編寫代碼 2、在前端中編寫js代碼 后端: ? ? ? ? ? 1、先導入依賴: ? ? ? ? ? 2、定義好配置文件 ? ? ? ? ? 3、編寫好實體類 ? ? ? ? ? 4、將幫助類進行配置 ? ? ? ? ? 5、編寫mapper類 ? ? ? ? ? 6、定義service層以及對應的

    2024年02月09日
    瀏覽(22)
  • 微信小程序3D,使用Three.js在微信小程序中展示gltf模型,使用VisionKit展示AR能力

    微信小程序3D,使用Three.js在微信小程序中展示gltf模型,使用VisionKit展示AR能力

    本倉庫只開源gltf模型展示技術,技術好的朋友有這些代碼就能幫助你解決很多問題了 如需要完整項目(基于若依框架開發(fā)的后端,AR能力前端)需另外付費贊助, 聯(lián)系方式:QQ 790002517 微信公眾號:時不待我 https://github.com/zzy-life/Wechat3D Three.js Three.js is a JavaScript 3D library. thr

    2024年02月09日
    瀏覽(49)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

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

二維碼1

領取紅包

二維碼2

領紅包