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

微信小程序?qū)崿F(xiàn)tab切換和數(shù)據(jù)列表

這篇具有很好參考價(jià)值的文章主要介紹了微信小程序?qū)崿F(xiàn)tab切換和數(shù)據(jù)列表。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

微信小程序?qū)崿F(xiàn)tab切換和數(shù)據(jù)列表

問題背景

上篇文章介紹了微信小程序?qū)崿F(xiàn)tab切換的一種方案(參考 https://blog.51cto.com/baorant24/6188157 ),感覺代碼不是很精簡(jiǎn),本文再用一個(gè)demo介紹微信小程序如何實(shí)現(xiàn)tab切換和數(shù)據(jù)列表。

問題分析

微信小程序?qū)?yīng)頁面文件結(jié)構(gòu)如下: 微信小程序tab切換,微信小程序,小程序,微信

問題解決

話不多說,直接上代碼: (1)index.js文件,代碼如下:

// pages/healdata/healthydata.ts
Page({
 
  /**
   * 頁面的初始數(shù)據(jù)
   */
  data: {
    currentIndex: 0, //默認(rèn)是活動(dòng)項(xiàng)
    home: "#979797",
    find: "#979797",
    services: "#00c2a5",
    mind: "#979797",
    homeChoose: false,
    findChoose: false,
    servicesChoose: true,
    mindChoose: false,
    msg: {},//消息數(shù)
    noNewMsg: true,//true表示新有新消息
    servicesAppiontData: [//服務(wù)預(yù)約數(shù)據(jù)列表
      {
      }],
    listItem: [
        {
            "deptId": 2098494533, 
            "packageId": 1, 
            "packageName": "院內(nèi)服務(wù)", 
            "services": [
                {
                    "serviceId": 1, 
                    "deptId": 2098494533, 
                    "brandName": "PICC護(hù)理", 
                    "serviceType": "1"
                }, 
                {
                    "serviceId": 2, 
                    "deptId": 2098494533, 
                    "brandName": "壓瘡護(hù)理", 
                    "serviceType": "1"
                }, 
                {
                    "serviceId": 3, 
                    "deptId": 2098494533, 
                    "brandName": "導(dǎo)尿管護(hù)理", 
                    "serviceType": "1"
                }, 
                {
                    "serviceId": 4, 
                    "deptId": 2098494533, 
                    "brandName": "胃管護(hù)理", 
                    "serviceType": "1",
                }
            ]
        }, 
        {
            "deptId": 2098494533, 
            "packageId": 2, 
            "packageName": "中醫(yī)服務(wù)", 
            "services": [
                {
                    "serviceId": 7, 
                    "deptId": 2098494533, 
                    "brandName": "失眠", 
                    "serviceType": "2"
                }, 
                {
                    "serviceId": 8, 
                    "deptId": 2098494533, 
                    "brandName": "便秘", 
                    "serviceType": "2"
                }, 
                {
                    "serviceId": 9, 
                    "deptId": 2098494533, 
                    "brandName": "頸椎病", 
                    "serviceType": "2"
                } 
            ]
        }, 
        {
          "deptId": 2098494533, 
          "packageId": 2, 
          "packageName": "中醫(yī)服務(wù)", 
          "services": [
              {
                  "serviceId": 10, 
                  "deptId": 2098494533, 
                  "brandName": "便秘", 
                  "serviceType": "2"
              }, 
              {
                  "serviceId": 11, 
                  "deptId": 2098494533, 
                  "brandName": "頸椎病", 
                  "serviceType": "2"
              } 
          ]
      }, 
    ],//數(shù)據(jù)列表數(shù)據(jù)
    patintIdS: ''
  },
 
  /**
   * 生命周期函數(shù)--監(jiān)聽頁面加載
   */
  onLoad() {
    
  },
 
  //點(diǎn)擊tab時(shí)觸發(fā)
  titleClick: function (e) {
    this.setData({
      //拿到當(dāng)前索引并動(dòng)態(tài)改變
      currentIndex: e.currentTarget.dataset.idx
    })
 
    //  console.log("======拿到當(dāng)前索引并動(dòng)態(tài)改變=dddd======")    
  },
 
  /**
   * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
   */
  onReady() {
 
  },
 
  /**
   * 生命周期函數(shù)--監(jiān)聽頁面顯示
   */
  onShow() {
 
    wx.hideHomeButton()
  },
 
  /**
   * 生命周期函數(shù)--監(jiān)聽頁面隱藏
   */
  onHide() {
 
  },
 
  /**
   * 生命周期函數(shù)--監(jiān)聽頁面卸載
   */
  onUnload() {
 
  },
 
  /**
   * 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作
   */
  onPullDownRefresh() {
 
  },
 
  /**
   * 頁面上拉觸底事件的處理函數(shù)
   */
  onReachBottom() {
 
  },
 
  /**
   * 用戶點(diǎn)擊右上角分享
   */
  onShareAppMessage() {
 
  }
})

(2)index.json文件,代碼如下:

{
  "usingComponents": {},
  "navigationBarTitleText": "分類列表",
  "navigationStyle": "custom"
}

(3)index.wxml文件,代碼如下:

<!-- 頭部搜索 -->
<view class="title_search">
</view>
<!-- 頭部搜索 -->
<!-- Tab布局 -->
<view catchtouchmove='true'>
  <view class='navBox'>
    <view class='titleBox1' id="allaid" bindtap='titleClick' data-idx='0'>
      <text class="{{0 == currentIndex ? 'fontColorBox' : 'fontColorBox1'}}">服務(wù)預(yù)約</text>
      <hr class="{{0 == currentIndex ? 'lineBox' : 'notLineBox'}}" />
    </view>
    <view class='titleBox2' bindtap='titleClick' data-idx='1'>
      <text class="{{1 == currentIndex ? 'fontColorBox' : 'fontColorBox1'}}">訂單消息</text>
      <hr class="{{1 == currentIndex ? 'lineBox' : 'notLineBox'}} " />
    </view>
  </view>
  <!-- 內(nèi)容布局 -->
  <swiper class='swiperTtemBox' bindchange='pagechange' current='{{currentIndex}}'>
    <!--服務(wù)預(yù)約 -->
    <swiper-item class='swiperTtemBox' catchtouchmove='onTouchMove'>
      <!-- 服務(wù)預(yù)約列表 -->
      <scroll-view class="box-scroll" scroll-y='true'>
        <!-- 服務(wù)列表 -->
        <block wx:for="{{listItem}}" wx:key="id" wx:for-item="itemName" wx:for-index="id">
          <view class="up_service">
            <view class="up_service_content">
              <!-- 上門服務(wù) -->
              <view class="up_service_title_txt">
                <text>
                  {{itemName.packageName }}
                </text>
              </view>
              <!-- 服務(wù)內(nèi)容 -->
              <view class="upitem_list">
                <block wx:for="{{itemName.services.length}}" wx:key="ids" wx:for-item="chilgrenItem" wx:for-index="ids">
                  <view class="item_nursin" catchtap="nursin_servies" id="{{itemName.services[ids].serviceId}}">
                    <text class="up_ser_it_txt" id="up_ser_it_txt_id" catchtap="nursin_servies" id="{{itemName.services[ids].serviceId}}">{{itemName.services[ids].brandName}}</text>
                  </view>
                </block>
              </view>
            </view>
          </view>
        </block>
      </scroll-view>
    </swiper-item>
    <!-- 訂單消息 -->
    <swiper-item class='swiperTtemBox' catchtouchmove='onTouchMove'>
      <view class="order_msg_md">暫無訂單消息</view>
    </swiper-item>
  </swiper>
</view>

(4)index.wxss文件,代碼如下:

Page {
  background: #f0f0f0;
  height: 100%;
  position: fixed;
}
/* 頭部搜索 */
/* 搜索標(biāo)題 */
.title_search{
  background: linear-gradient(to right, #0455a7, #62c8ec);
  height: 170rpx;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-start;
}
.seeck_md{
  display: flex;
  flex-direction: row;
  width: 100%;
  justify-content: space-between;
  align-items: flex-end;
}
.ahead_md{
  display: flex;
  flex-direction: row;
  width: 100%;
  margin-bottom: 20rpx;
}
 
.title_icon_ss{
  height: 70rpx;
  width: 70rpx;
  background-color: white;
  border-radius: 35rpx;
  margin-left: 20rpxrpx;
}
/* 搜索部分bg*/
.search_md{
  background-color: #69ccf1;
  margin-left: 10rpx;
  height: 70rpx;
  width: 390rpx;
  border-radius: 35rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
 
/* 搜索 */
.seeck_ic{
  height: 46rpx;
  width: 46rpx;
  margin-left: 20rpx;
  border-radius: 23rpx;
}
/* 語音 */
.vioce_icon{
  height: 46rpx;
  width: 46rpx;
  border-radius: 23rpx;
  margin-right: 20rpx;
}
/* 消息 */
.msg{
  width: 100rpx;
  height: 90rpx; 
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-right: 0rpx;
  margin-left: 30rpx;
}
 
/* 消息提示 */
.msg_tag{
  position: absolute;
  background-color: #ff6162;
  width: 14rpx;
  height: 14rpx;
  border-radius: 7rpx;
  margin-bottom: 72rpx;
  margin-left: 24rpx;
}
 
.msg_ic{
  height: 44rpx;
  width: 48rpx;
  margin-right: 2rpx;
  margin-right: 10rpx;
}
.msg_txt{
  font-size: 24rpx;
  height: 40rpx;
  width: 60rpx;
  margin-bottom: 20rpx;
  align-items: flex-start;
  color: #fff;
  display: flex;
  justify-content: flex-start;
}
/* 退出 */
.logout{
  width: 100rpx;
  height: 90rpx; 
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-right: 30rpx; 
}
.logout_ic{
  height: 44rpx;
  width: 48rpx;
  margin-right: 2rpx;
}
.logout_txt{
  font-size: 24rpx;
  height: 40rpx;
  width: 60rpx;
  margin-bottom: 20rpx;
  align-items: flex-start;
  color: #fff;
  display: flex;
  justify-content: flex-start;
}
/* 搜索標(biāo)題 */
/* 頭部搜索  */
.box-scroll{
  background-color: #EFEFEF;
  width: 100%;
  flex: 1 auto;
  height: calc(100vh - 260rpx);
  left: 0rpx;
  right: 0rpx;
  top: 0rpx;
  padding-bottom: 0rpx;
}
 
/* .box-scroll {
  flex: 1 auto;
  height: calc(100vh - 390rpx);
  left: 0rpx;
  right: 0rpx;
  top: 0rpx;
  padding-bottom: 20rpx;
} */
 
/* 頂部切換 */
.navBox {
  /* 頂部tab盒子樣式 */
  width: 100%;
  height: 80rpx;
  background: white;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}
 
/* 文字默認(rèn)顏色 */
.fontColorBox {
  color: #07c8ae;
}
 
.fontColorBox1 {
  color: black;
}
 
/* 文字默認(rèn)顏色 */
.titleBox1,
.titleBox2 {
  /* 未選中文字的樣式 */
  width: 50%;
  font-size: 30rpx;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-top: 10rpx;
}
 
.lineBox,
.notLineBox {
  /* 選中及未選中底線共同樣式 */
  width: 100%;
  height: 4rpx;
  margin-top: 16rpx;
  border-radius: 4rpx;
}
 
.lineBox {
  /* 選中底線樣式 */
  background: #06c7ae;
  width: 100%;
  height: 4rpx;
  margin-top: 16rpx;
  border-radius: 4rpx;
}
 
.notLineBox {
  /* 未選中底線樣式 */
  background: transparent;
  width: 100%;
  height: 4rpx;
}
 
/* 底部內(nèi)容樣式 */
.swiperTtemBox {
  height: 100vh;
  overflow: scroll;
  margin: 0rpx 0rpx;
  background: #f0f0f0;
  border-radius: 30rpx;
  font-size: 28rpx;
  margin-top: 5rpx;
}
 
/* 頂部切換 */
.up_service {
  justify-content: left;
  padding-left: 40rpx;
  padding-right: 40rpx;
}
 
.up_service_content {
  justify-content: space-between;
}
 
.up_service_title_txt {
  color: #666666;
}
 
.upitem_list {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
}
 
.item_nursin {
  width: 320rpx;
  height: 200rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  flex-grow: 0;
  margin-top: 30rpx;
  background-color: white;
  border-radius: 20rpx;
}
 
.up_service_icon {
  width: 130rpx;
  height: 110rpx;
  border-radius: 10rpx;
  margin-top: 10rpx;
}
 
#up_ser_it_txt_id {
  color: #1b1b1b;
  font-size: 32rpx;
  margin-top: 10rpx;
}
 
.cn_medicine {
  margin-top: 30rpx;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
 
/* 院內(nèi)服務(wù) */
.hospital_service {
  justify-content: left;
  padding-left: 40rpx;
  padding-right: 40rpx;
  margin-top: 10rpx;
}
 
.order_msg_md{
  display: flex;
  margin-top: 30rpx;
  align-items: center;
  justify-content: center;
  color: #919199;
}
 
 
.scroll-view_H {
  overflow: scroll;
  white-space: nowrap;
  background-color: white;
  margin-right: 30rpx;
}
 
.head_list {
  display: flex;
  /* display: inline-block; */
  flex-direction: row;
  background-color: white;
  height: 160rpx;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}
 
/* 家屬選擇背景 */
.head_list_item_one {
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  flex-direction: column;
  background-color: #f0f0f0;
  width: 140rpx;
  height: 140rpx;
  align-items: center;
  justify-content: center;
  margin-left: 30rpx;
  border-radius: 10rpx;
}
 
/* 家屬選背景 */
.head_list_item_one_ed {
  display: flex;
  flex-direction: column;
  background-color: #06c7ae;
  flex-shrink: 0;
  flex-grow: 0;
  width: 140rpx;
  height: 140rpx;
  align-items: center;
  justify-content: center;
  margin-left: 30rpx;
  border-radius: 10rpx;
}
 
.head_list_item_one_im_parent {
  background-color: white;
  width: 80rpx;
  height: 80rpx;
  border-radius: 40rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.head_list_item_one_im {
  width: 72rpx;
  height: 72rpx;
  border-radius: 36rpx;
  background-color: white;
}
 
.head_list_item_one_txt {
  margin-top: 6rpx;
  font-size: 26rpx;
  color: #252525;
}
 
.head_list_item_one_txt_ed {
  margin-top: 6rpx;
  font-size: 26rpx;
  color: #ffffff;
}
 
.first {
  margin-top: 20rpx;
}

運(yùn)行結(jié)果如下: 微信小程序tab切換,微信小程序,小程序,微信

問題總結(jié)

本文介紹了微信小程序如何實(shí)現(xiàn)tab切換和數(shù)據(jù)列表,有興趣的同學(xué)可以進(jìn)一步深入研究。文章來源地址http://www.zghlxwxcb.cn/news/detail-754125.html

到了這里,關(guān)于微信小程序?qū)崿F(xiàn)tab切換和數(shù)據(jù)列表的文章就介紹完了。如果您還想了解更多內(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)文章

  • 【微信小程序】實(shí)現(xiàn)頁面tab切換效果

    【微信小程序】實(shí)現(xiàn)頁面tab切換效果

    目錄 前言 本次效果展示 一、如何實(shí)現(xiàn)頁面tab 1.使用內(nèi)置組件scroll-view 2.實(shí)現(xiàn)點(diǎn)擊時(shí)出現(xiàn)的背景樣式 3.使用scroll-into-view,實(shí)現(xiàn)點(diǎn)擊時(shí)自動(dòng)滾動(dòng) 本次主要內(nèi)容是介紹頁面tab的開發(fā),如何實(shí)現(xiàn)tab與頁面內(nèi)容聯(lián)動(dòng)呢?關(guān)注我就知道! ? 如下圖所示,我們需要使用到紅色框框中的屬

    2024年02月09日
    瀏覽(505)
  • 快速掌握微信小程序 tab 切換的實(shí)現(xiàn)技巧(可滑動(dòng)切換)

    快速掌握微信小程序 tab 切換的實(shí)現(xiàn)技巧(可滑動(dòng)切換)

    微信小程序中的 tab 切換功能可以說是用戶所需的一個(gè)基礎(chǔ)功能。本文將介紹如何通過微信小程序?qū)崿F(xiàn) tab 切換功能,為用戶帶來更為便捷和高效的小程序體驗(yàn)。 其實(shí)這個(gè)小功能的實(shí)現(xiàn)非常簡(jiǎn)單,只需要通過一個(gè)標(biāo)識(shí)控制選項(xiàng)的樣式及顯示的內(nèi)容,當(dāng)我們觸發(fā)點(diǎn)擊或者滑動(dòng)事

    2024年02月11日
    瀏覽(365)
  • uniapp 微信小程序?qū)崿F(xiàn)監(jiān)聽屏幕左右滑動(dòng)實(shí)現(xiàn)tab標(biāo)簽切換效果

    ? ? ? ? 實(shí)際的項(xiàng)目開發(fā)之中,有很多所謂的奇葩需求,當(dāng)工程量相對(duì)較大的時(shí)候去更換組件會(huì)顯得特別麻煩和費(fèi)時(shí)。我這次的需求因?yàn)槟承┨厥庠?,更換組件后也無法實(shí)現(xiàn)需要達(dá)到的效果,所以最后只能監(jiān)聽滑動(dòng)事件,相信你看了我的代碼也能輕松搞定! ?????????

    2024年02月14日
    瀏覽(97)
  • 微信小程序tab加列表demo

    微信小程序tab加列表demo

    一、效果 代碼復(fù)制即可使用,記得把圖標(biāo)替換成個(gè)人工程項(xiàng)目圖片。 微信小程序開發(fā)經(jīng)常會(huì)遇到各種各樣的頁面組合,本demo為list列表與tab組合,代碼如下: 二、json代碼 三、xml 四、css 五、ts代碼

    2024年02月14日
    瀏覽(17)
  • 微信小程序 列表多選 下拉分頁 滑動(dòng)切換分類

    微信小程序 列表多選 下拉分頁 滑動(dòng)切換分類

    1、卡片列表 2、分頁(下拉頁面加載分頁數(shù)據(jù)) 3、分類(頁面間互不干擾,數(shù)據(jù)也不干擾) 4、左右滑動(dòng)可切換分類 5、列表搜索 6、單選模式(默認(rèn)單選模式,即點(diǎn)擊卡片,回寫所選數(shù)據(jù)) 7、 多選 模式(實(shí)現(xiàn)微信聊天多選效果) 長按 列表或 點(diǎn)擊多選 ,進(jìn)入多選模式;

    2024年02月03日
    瀏覽(22)
  • 微信小程序?qū)崿F(xiàn)左右滑動(dòng)進(jìn)行切換數(shù)據(jù)頁面(touchmove)

    微信小程序?qū)崿F(xiàn)左右滑動(dòng)進(jìn)行切換數(shù)據(jù)頁面(touchmove)

    手指觸摸左右滑動(dòng)進(jìn)行切換數(shù)據(jù) 需要實(shí)現(xiàn)的是有一個(gè)tab欄,點(diǎn)選某一個(gè)tab的時(shí)候切換頁面,手勢(shì)滑動(dòng),左滑右滑效果和點(diǎn)擊tab一樣切換頁面數(shù)據(jù)。 這里我們要先了解幾個(gè)微信的事件屬性 touchstart : 手指觸摸動(dòng)作開始 touchmove:手指觸摸后移動(dòng) touchcancel:手指觸摸動(dòng)作被打斷,

    2024年02月11日
    瀏覽(87)
  • 【微信小程序】頁面tab欄與頁面內(nèi)容聯(lián)動(dòng)_微信小程序?qū)崿F(xiàn)tabs跟下面的內(nèi)容聯(lián)動(dòng)

    【微信小程序】頁面tab欄與頁面內(nèi)容聯(lián)動(dòng)_微信小程序?qū)崿F(xiàn)tabs跟下面的內(nèi)容聯(lián)動(dòng)

    先自我介紹一下,小編浙江大學(xué)畢業(yè),去過華為、字節(jié)跳動(dòng)等大廠,目前阿里P7 深知大多數(shù)程序員,想要提升技能,往往是自己摸索成長,但自己不成體系的自學(xué)效果低效又漫長,而且極易碰到天花板技術(shù)停滯不前! 因此收集整理了一份《2024年最新大數(shù)據(jù)全套學(xué)習(xí)資料》,

    2024年04月28日
    瀏覽(91)
  • 微信小程序 如何實(shí)現(xiàn)列表

    微信小程序中實(shí)現(xiàn)列表可以通過使用「scroll-view」組件或「list」組件來實(shí)現(xiàn)。 使用「scroll-view」組件:可以使用 wx:for 指令來循環(huán)渲染列表中的數(shù)據(jù),并為每個(gè)元素設(shè)置相應(yīng)的樣式。 使用「list」組件:該組件已經(jīng)內(nèi)置了列表的常用功能,包括列表渲染、上拉加載、下拉刷新等

    2024年02月11日
    瀏覽(16)
  • 【微信小程序入門到精通】— 微信小程序?qū)崿F(xiàn)多頁面切換(tabBar)

    【微信小程序入門到精通】— 微信小程序?qū)崿F(xiàn)多頁面切換(tabBar)

    對(duì)于目前形式,微信小程序是一個(gè)熱門,那么我們?cè)撊绾稳W(xué)習(xí)并且掌握之后去做實(shí)際項(xiàng)目呢? 為此我特意開設(shè)此專欄,在我學(xué)習(xí)的同時(shí)也將其分享給大家! 本篇文章將給大家?guī)砣绾翁砑禹撁媲袚Q效果,我們前面所講解的都是停留在某一頁面上面進(jìn)行預(yù)覽,接下來我們將

    2024年02月03日
    瀏覽(166)
  • 小程序 | 微信小程序?qū)崿F(xiàn)商品分類列表

    小程序 | 微信小程序?qū)崿F(xiàn)商品分類列表

    小程序 | 微信小程序?qū)崿F(xiàn)商品分類列表 一、效果展示 二、代碼實(shí)現(xiàn)

    2024年02月11日
    瀏覽(20)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包