最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序仿淘寶熱搜詞在搜索框中輪播功能

 更新時(shí)間:2020年01月21日 14:38:48   作者:玩爛小程序  
這篇文章主要介紹了微信小程序—仿淘寶熱搜詞在搜索框中輪播功能的相關(guān)資料,需要的朋友可以參考下

摘要

逛淘寶的時(shí)候,發(fā)現(xiàn)淘寶搜索框中一直在垂直方向上輪播熱搜提示詞,覺(jué)得這是個(gè)不錯(cuò)的設(shè)計(jì),除了能讓空間更充分使用,也能讓頁(yè)面更有動(dòng)感,最重要的是能夠增加搜索框的使用頻率。就在小程序中試著實(shí)現(xiàn)實(shí)現(xiàn)。

效果

在這里插入圖片描述

體驗(yàn)

在這里插入圖片描述

實(shí)現(xiàn)思路

思路比較簡(jiǎn)單,主要是兩點(diǎn),

1:input處于熱搜提示詞上層,用z-index實(shí)現(xiàn)
2:熱搜詞輪播用swiper實(shí)現(xiàn),方向?yàn)関ertical
3:在input聚焦時(shí)獲取swiper當(dāng)前值,設(shè)置為placeholder
4:將swiper隱藏

代碼

已封裝成組件

組件代碼:

wxss

<view class="swiper-view">
 <swiper class="swiper_container" vertical="true" autoplay="true" circular="true" interval="2000">
  <block wx:for="{{msgList}}">
   <swiper-item>
    <view class="swiper_item">{{item.title}}</view>
   </swiper-item>
  </block>
 </swiper>
</view>

wxss

.container {
 width: 100%;
 height: 80rpx;
 display: flex;
 flex-direction: row;
 justify-content: center;
 align-items: center;
 background: #ededed;
}

.search-container {
 width: 690rpx;
 height: 60rpx;
 display: flex;
 flex-direction: row;
 justify-content: flex-start;
 align-items: center;
 background: #fff;
 border-radius: 5rpx;
}

.swiper_container {
 margin-left: 15rpx;
 height: 60rpx;
 width: 100%;
 display: flex;
 flex-direction: row;
 justify-content: flex-start;
 align-items: center;
 position:absolute;
 z-index:1;
}

.swiper_item {
 height: 60rpx;
 font-size: 26rpx;
 color: #999;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
 display: flex;
 flex-direction: row;
 justify-content: flex-start;
 align-items: center;
}

js

Component({
 /**
  * 組件的屬性列表
  */
 properties: {
  msgList:{
   type:JSON,
   value: []
  }
 },

 /**
  * 組件的初始數(shù)據(jù)
  */
 data: {
  placeholder:'',
  currentIndex:0,
  index:0,
  isFocus:false,
  msgList: [],
  content:'',
  confirmContent:''
 },

 ready(){
  this.setData({
   msgList:this.properties.msgList
  })
 },
 /**
  * 組件的方法列表
  */
 methods: {
  changeIndex(e){
   this.setData({
    index:e.detail.current
   })
  },
  focusInput(){
   this.setData({
    isFocus:true,
    placeholder:this.data.msgList[this.data.index].title
   })
  },
  blurInput(){
   if (this.data.content == ""){
    this.setData({
     isFocus: false,
     currentIndex: this.data.index,
     placeholder: ''
    })
   }
  },
  confirm(e){
   var confirmContent = ''
   if(e.detail.value==''){
    confirmContent = this.data.placeholder
   }else{
    confirmContent = e.detail.value
   }

   this.triggerEvent('search', {confirmContent})
  },
  inputContent(e){
   this.setData({
    content: e.detail.value
   })
  }
 }
})

json

{
 "component": true,
 "usingComponents": {}
}

頁(yè)面代碼

js

Page({
 data: {
  msgList: [
   { title: "朋友圈" },
   { title: "文章" },
   { title: "公共號(hào)" },
   { title: "小程序" },
   { title: "音樂(lè)" },
   { title: "表情" },
   { title: "訂閱號(hào)" }]
 },
 search(e){
  wx.showToast({
   icon:"none",
   title: "正在搜索"+e.detail.confirmContent,
  })
 }
})

wxss

<swiperSearch msgList="{{msgList}}" bind:search="search"></swiperSearch>

總結(jié)

以上所述是小編給大家介紹的微信小程序仿淘寶熱搜詞在搜索框中輪播功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!

相關(guān)文章

最新評(píng)論

南川市| 绥江县| 平南县| 赞皇县| 江西省| 德兴市| 宣恩县| 启东市| 墨玉县| 故城县| 毕节市| 子长县| 望谟县| 青田县| 淮北市| 榆中县| 盐源县| 枣阳市| 磴口县| 盐边县| 五寨县| 什邡市| 景宁| 双桥区| 漳平市| 准格尔旗| 宜川县| 运城市| 龙海市| 府谷县| 潍坊市| 峨眉山市| 肥西县| 内乡县| 河北区| 淅川县| 锦屏县| 高平市| 瓦房店市| 新密市| 温泉县|