知趣
知趣
  • 发布:2026-04-17 09:51
  • 更新:2026-04-17 09:53
  • 阅读:26

app端 swiper在华为P30 Pro(HarmonyOS 2.0.0)滑不动

分类:uni-app

项目启动页:(提交至华为应用市场时,未审核通过,这个启动页点不动也滑不动)

<template>  
  <view class="">  
    <view v-if="showGuide" class="guide-container">  
      <swiper   
        :indicator-dots="true"   
        :autoplay="false"   
        :circular="false"   
        @change="swiperChange"  
        class="swiper"  
      >  
        <swiper-item v-for="(item, index) in guideImages" :key="index" @click="finishGuide(index)">  
          <image :src="item" mode="aspectFill" class="image" />  
        </swiper-item>  
      </swiper>  
    </view>  
    <view class="container" v-else>  
      <image   
        class="splash-image"   
        src="/static/images/imgs/lanch.png"  
        mode="aspectFill"   
      />  
    </view>  
  </view>  
</template>  

<script>  
export default {  
  data() {  
    return {  
      showGuide: true,  
      current: 0, // 初始化当前Swiper索引  
      guideImages: [  
        '/static/images/imgs/launch1.png',  
        '/static/images/imgs/launch2.png',  
        '/static/images/imgs/launch3.png'  
      ]  
    }  
  },  
  onLoad() {  
    // 检查用户是否已启动过应用,如果已经启动,则跳过引导页  
    const hasLaunched = uni.getStorageSync('hasLaunched');  
        console.log('hasLaunched', hasLaunched)  
    if (hasLaunched) {  
      this.showGuide = false;  
    } else {  
      this.showGuide = true;  
    }  
  },  
  methods: { // 注意这里应为methods而不是motheds  
    swiperChange(e) {  
      this.current = e.detail.current;  
    },  
    finishGuide(e) {  
            if (e != 2) return   
      // 设置已启动标记  
      uni.setStorageSync('hasLaunched', true);  
      let token = uni.getStorageSync('token');  
      let type = uni.getStorageSync('access');  
      if (token) {  
        // 已登录,根据type跳转  
        if (type == null || type == '') {  
          uni.reLaunch({  
            url: '/pages/tabbar/worktable',  
          });  
          return;  
        }  
        if (type == '1101' || type == '1102' || type == '1103') {  
          let need_perfect_information = uni.getStorageSync('need_perfect_information');  
          if (need_perfect_information == 'notReviewed') {  
            uni.reLaunch({  
              url: '/pages/tabbar/unverified',  
            });  
          } else {  
            uni.reLaunch({  
              url: '/pages_hotel/tabbar/worktable'  
            });  
          }  
        } else if (['1104', '1105', '1106', '1107', '1108', '1109', '1113'].includes(type)) {  
          uni.reLaunch({  
            url: '/pages/tabbar/worktable'  
          });  
        }  
      } else {  
        // 未登录,跳转登录页  
        uni.reLaunch({  
          url: '/pages/login/login'  
        });  
      }  
    }  
  }  
};  
</script>  

<style lang="scss" scoped>  
.container {  
  position: relative;  
  width: 100vw;  
  height: 100vh;  
  overflow: hidden;  

  .splash-image {  
    width: 100%;  
    height: 100%;  
  }  

  .loading-icon {  
    position: absolute;  
    bottom: 100rpx;  
    left: 50%;  
    transform: translateX(-50%);  
  }  
}  
/* 保持之前的样式 */  
.guide-container {  
  position: relative;  
  height: 100vh;  
}  
.swiper {  
  height: 100%;  
}  
.image {  
  width: 100%;  
  height: 100%;  
}  
.btn-container {  
  position: absolute;  
  bottom: 80rpx;  
  left: 50%;  
  transform: translateX(-50%);  

}  
.btn {  
    width: 256rpx;  
    line-height: 62rpx;  
  background: linear-gradient( 90deg, #8DA7F4 0%, #366AF5 100%);  
  color: #FFFFFF;  
    font-weight: 500;  
    font-size: 32rpx;  
  border-radius: 24rpx;  
}  
</style>
2026-04-17 09:51 负责人:无 分享
已邀请:
Ask小助手

Ask小助手 - Ask社区AI助手

根据知识库检索,针对华为 P30 Pro(HarmonyOS 2.0.0)swiper 滑不动的问题,知识库中暂未找到该特定设备和系统的兼容性解决方案。

不过,知识库中提供了关于 swiper 在 App 端(Android/iOS)的重要注意事项,可能与此问题相关:

swiper 高度设置问题
根据 swiper 组件文档,app-android 和 iOS 端的 swiper 目前默认会以内容高度撑开作为其高度。如果要多端拉齐应自行设置 swiper 的 style 高度。若 swiper-item 内部使用绝对定位,无法撑开 swiper,组件默认高度为 150px。

建议尝试以下方案:

  1. 明确设置 swiper 高度:确保 .swiper 类有明确的高度计算,尝试将高度设置为具体像素值或确保父容器高度正确传递

    .swiper {  
     height: 100vh; /* 或具体数值如 1334rpx */  
    }  

    本助手使用国产模型,生成代码可能不准确。专业的代码生成需要全球顶尖的AI Coding模型。推荐使用uni-agent

  2. 使用插件市场替代组件:如果原生 swiper 在特定设备上存在兼容性问题,建议尝试使用插件市场的 swiper 组件,如 wyh-swiperml-swiper-v3 等社区组件。

知识库限制说明
知识库中暂无关于华为 HarmonyOS 2.0.0 系统上 swiper 触摸滑动失效的特定修复方案。如问题持续,建议到 DCloud 社区 提交该设备的兼容性反馈,或考虑使用自定义触摸滑动组件替代原生 swiper。

内容为 AI 生成,仅供参考

要回复问题请先登录注册