uniapp 仿微信的右边下拉选择弹出框的实现代码

这个组件主要是包括搜索框和右边菜单点击弹出一个下拉筛选菜单

 这里首先用一个单独的页面存放这个组件

<template>
//这里是搜索框的输入框 不需要的可以删掉
 <view>
 <view class="arrivalSearch">
  <view class="arrivalSmallsearch">
   <view class="arrivalSearchInput">
   <input type="text" :placeholder="dateinit">
   </view>
   //这里是输入框旁边的图标(这里的图标是一张图片)
   <image src="../../static/img/nav.png" mode="aspectFill" @click.stop="ShowHidden = !ShowHidden"> </image>
  </view>
 </view>
 //这里是弹出来的下拉筛选框
 <view class="arrivalNavigation" v-if="ShowHidden">
  <view class="d4"></view>
  <view class="sideNavigation">
  <nav>
  <ul>
   <navigator url="../arrivalQuery/arrivalQuery">
   <li>到货查询</li>
   </navigator>
   <view class="liBottomBorder"></view>
  <navigator url="../retailStore/retailStore"><li>门店查询</li></navigator>
   <view class="liBottomBorder"></view>
   <navigator url="../itemNoQuery/itemNoQuery"><li>货号查询</li></navigator>
   <view class="liBottomBorder"></view>
   <navigator url="../priceReductionQuery/priceReductionQuery"><li>降价查询</li></navigator>
  </ul>
  </nav>
  </view>
 </view>
 </view>
</template>
 
<script>
 export default {
  data() {
  return {
   ShowHidden: false,
   dateinit:'请输入货号',
  };
  },
  methods: {
   // 点击页面事件 隐藏需要隐藏的区域
   HiddenClick () {
    this.ShowHidden = false
   },
  },
  mounted () {
    // document.addEventListener('click', this.HiddenClick)
   },
 }
</script>
 
<style lang="less">
 .arrivalSearch{
  width: 100%;
  height: 100rpx;
  background-color: #fff;
  box-shadow: 0 0 10rpx #eee;
 .arrivalSmallsearch{
  width: 96%;
  display: flex;
  .arrivalSearchInput{
    height: 70rpx;
    background-color: #F0F1F6;
    border-radius: 40rpx;
    font-size: 25rpx;
    margin-left: 10rpx;
    margin-top: 10rpx;
    width: 608rpx;
  }
  input{
  width: 80%;
    margin-left: 40rpx;
  margin-top: 10rpx;
  }
  image{
  width: 40rpx;
  height: 40rpx;
  margin-left: 20rpx;
  margin-top: 20rpx;
  }
 }
 
 }
 //从这里开始是弹出框的样式 不需要搜索框的 前面样式都不用加
 .arrivalNavigation{
  width: 250rpx;
  position: absolute;
   right:20rpx;
  z-index: 99;
  .sideNavigation{
   width: 248rpx;
   background-color: #202020;
   color: #eee;
   border-radius: 10rpx;
    li{
    height: 85rpx;
    text-align: center;
    line-height: 85rpx;
    font-size: 25rpx;
    }
    .liBottomBorder{
   border: 0.1rpx solid #373737;
    }
 
   }
   .d4{
   // position: absolute;
   //  left: 140rpx;
    width: 0;
    height: 0;
   margin-left: 150rpx;
   margin-top: -20rpx;
    border-width:20rpx;
    border-style: solid;
    border-color: transparent #333 transparent transparent;
    transform: rotate(90deg); /*顺时针旋转90°*/
 
   }
  }
</style>

然后在main.js中引入页面

import springBox from 'pages/springBox/springBox'
Vue.component('springBox',springBox)

最后直接在需要使用的页面使用组件就可以了

<springBox></springBox>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Uniapp 是一个基于 Vue.js 的跨平台架,可以用它来开发 Web、iOS、Android 等多个平台的应用。而仿微信聊天下拉刷新则是一种常见的 UI 效果,当用户下拉聊天记录时,页面会出现下拉刷新的效果,以展示最新的聊天记录。 在 Uniapp实现仿微信聊天下拉刷新,可以通过使用下拉刷新组件来完成。首先,在需要实现下拉刷新的页面中引入 uni-app 组件库,然后在该页面的 template 中添加下拉刷新组件,示例代码如下: ```html <template> <view> <scroll-view scroll-y="true" class="chat-scrollview" :style="{height:chatScrollHeight}"> <!-- 聊天记录列表 --> <view class="chat-list"> ... </view> </scroll-view> <!-- 下拉刷新组件 --> <uni-scroll-view refresher-enabled :refresher-threshold="80" @refresherrefresh="onRefresh"> <view slot="refresher" class="uni-refresher"> <i class="uni-icons" :class="{'uni-loading':isRefreshing}"></i> <span v-if="isRefreshing">正在刷新...</span> <span v-else>下拉刷新</span> </view> </uni-scroll-view> </view> </template> <script> import uniScrollView from '@/components/uni-scroll-view/uni-scroll-view.vue' export default { components: { uniScrollView }, data() { return { chatScrollHeight: '100vh', isRefreshing: false } }, methods: { onRefresh() { // 下拉刷新回调函数 this.isRefreshing = true; setTimeout(() => { this.isRefreshing = false; }, 2000); } } } </script> <style lang="scss"> .chat-scrollview { height: calc(100vh - 100rpx); } .uni-refresher { display: flex; align-items: center; justify-content: center; height: 80rpx; color: #999; font-size: 28rpx; line-height: 1; } </style> ``` 在这段代码中,我们使用了 uni-app 自带的 `uni-scroll-view` 组件作为下拉刷新组件,并设置了 `refresher-enabled` 属性为 true,表示开启下拉刷新功能。同时,我们在组件中设置了 `refresher-threshold` 属性为 80,表示下拉超过 80rpx 才会触发下拉刷新的回调函数 `onRefresh`。当用户下拉到阈值时,会触发 `@refresherrefresh` 事件,我们在这个事件中执行下拉刷新的逻辑。在代码中,我们设置了一个 `isRefreshing` 变量来控制刷新状态,当 `isRefreshing` 为 true 时,显示“正在刷新...”文本和 loading 图标,当 `isRefreshing` 为 false 时,显示“下拉刷新”文本。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值