帖子
帖子
用户
博客
课程
显示全部楼层
38
帖子
4
勋章
1万+
Y币

[多端开发] avm中通用事件中的touch事件有问题

[复制链接]
发表于 2022-2-17 16:06:38
本帖最后由 Hello_绿洲 于 2022-2-17 16:09 编辑

avm中通用事件中的touch事件存在问题,页面分为页面A和页面B,页面A中放置一个头部,使用普通的view或者act中的a-nav-bar组件都试过,然后并列元素frame引入页面B,在页面B中的按钮touch事件监听手指按住上移,手指不松开,离开按钮位置,不行的时候会进入到touchcancel,可以的时候还是touchmove,手指松开才会进入到touchend,页面A中头部的高度过大或者过小,会导致页面B中按钮touch事件发生不行的情况,手指在按钮处按住上移,手指不松开,离开按钮位置,会进入到touchcancel
页面A
  1. <template>
  2.   <view class="">
  3.     <!-- 1.尝试过程,传height为44是可以的,数值大了或小了不行 -->
  4.     <!-- <a-nav-bar title="222" :hide-line="false" :height="68" left-arrow>
  5.     </a-nav-bar> -->
  6.       
  7.     <!-- 2.尝试过程,nav的里的height为88px可以,大了或小了不行 -->
  8.    <!--  <view class="nav">/view> -->

  9.     <!-- 3.尝试过程,此处是直接将act中的a-nav-bar拷过来 -->
  10.     <safe-area class="a-nav-bar">
  11.       <!-- !!!!!此处style里的height传30,80不行,44,50啥的就可以,好像太大太小都不行 -->
  12.       <view class="a-nav-bar__content" style="height: 30px">
  13.         <view class="a-nav-bar__click-warp a-nav-bar__left" _slot="left" @click="leftClick">
  14.           <image src="../../image/back.png" class="a-nav-bar__icon" />
  15.         </view>
  16.         <text class="a-nav-bar__title" style="font-size: 16px;color: #000;" @click="titleClick">
  17.           22222
  18.         </text>
  19.       </view>
  20.     </safe-area>

  21.     <!-- 以下保持不变 -->
  22.     <frame class="" avm="true" name="test1_frm" url="../test1_frm/test1_frm.stml">
  23.     </frame>
  24.   </view>
  25. </template>
  26. <script>
  27.   // import ANavBar from "../../components/act/a-nav-bar";
  28.   export default {
  29.     name: 'test1',
  30.     apiready() {
  31.       console.log(api.safeArea.top)
  32.     },
  33.     install() {

  34.     },
  35.     installed() {
  36.     },
  37.     data() {
  38.       return {
  39.       }
  40.     },
  41.     methods: {

  42.     }
  43.   }
  44. </script>

  45. <style>
  46.   /* common */
  47.   .nav {
  48.     width: 100%;
  49.     height: 68px;
  50.   }

  51.   .a-nav-bar {
  52.     background-color: #fff;
  53.   }

  54.   .a-nav-bar--line {
  55.     box-shadow: 1px 1px 1px #e6e6e6;
  56.     margin-bottom: 2px;
  57.   }

  58.   .a-nav-bar__content {
  59.     flex-flow: row nowrap;
  60.   }


  61.   .a-nav-bar__click-warp {
  62.     position: absolute;
  63.     height: 100%;
  64.     flex-flow: row nowrap;
  65.     align-items: center;
  66.     padding: 0 16px;
  67.     z-index: 99;
  68.   }

  69.   .a-nav-bar__left {
  70.     left: 0;
  71.   }

  72.   .a-nav-bar__right {
  73.     right: 0;
  74.   }

  75.   .a-nav-bar__text {
  76.     color: #333;
  77.     font-size: 14px;
  78.   }

  79.   .a-nav-bar__icon {
  80.     height: 16px;
  81.     width: 16px;
  82.   }

  83.   .a-nav-bar__title {
  84.     display: flex;
  85.     justify-content: center;
  86.     align-items: center;
  87.     flex: 1;
  88.     font-family: PingFangSC-Medium, PingFang SC;
  89.     align-self: center;
  90.     text-align: center;
  91.     font-weight: 500;
  92.     white-space: nowrap;
  93.     text-overflow: ellipsis;
  94.     overflow: hidden;
  95.   }
  96. </style>
复制代码

页面B

  1. <template>
  2.   <view class="page">
  3.     <scroll-view class="scroll-view flex" show-scrollbar="false" scroll-y></scroll-view>
  4.     <view class="chat-operating disflex disflex-middle" id="chatOperating">
  5.       <view class="flex">
  6.         <view id="voiceButton" class="chat-input-box">
  7.           <!-- 手指按住上移,手指不松开,离开按钮位置,不行的时候会进入到touchcancel,可以的时候还是touchmove,手指松开才会进入到touchend -->
  8.           <view id="" class="chat-voice-word-box" @longpress="voiceLongpress"
  9.             @touchstart="voiceTouchstart" @touchmove="voiceTouchmove" @touchend="voiceTouchend"
  10.             @touchcancel="voiceTouchcancel">
  11.             <text class="chat-voice-word fz14 c-33344A">按住 说话</text>
  12.           </view>
  13.         </view>
  14.       </view>
  15.     </view>
  16.     <safe-area class="b-fff"></safe-area>
  17.   </view>
  18. </template>
  19. <script>
  20.   // import ANavBar from "../../components/act/a-nav-bar";
  21.   export default {
  22.     name: 'test1_frm',
  23.     apiready() {
  24.     },
  25.     install() {

  26.     },
  27.     installed() {
  28.     },
  29.     data() {
  30.       return {
  31.       }
  32.     },
  33.     methods: {
  34.       voiceLongpress(e) {
  35.         console.log("-----longpress----")
  36.       },
  37.       voiceTouchstart(e) {
  38.         console.log("-----touchstart----")
  39.       },
  40.       voiceTouchmove(e) {
  41.         console.log("-----touchmove----")
  42.       },
  43.       voiceTouchend(e) {
  44.         console.log("-----touchend----")
  45.       },
  46.       voiceTouchcancel(e) {
  47.         console.log("-----touchcancel----")
  48.       },
  49.     }
  50.   }
  51. </script>
  52. <style>
  53.   .flex {
  54.     flex: 1;
  55.   }

  56.   .page {
  57.     width: 100%;
  58.     height: 100%;
  59.   }

  60.   .scroll-view{
  61.     background-color: #4bc5f5;
  62.   }

  63.   .chat-operating {
  64.     width: 100%;
  65.     min-height: 52px;
  66.     background: #ffffff;
  67.     padding: 7px 14px;
  68.     z-index: 9999;
  69.   }

  70.   .chat-operating-img {
  71.     width: 23px;
  72.     height: 23px;
  73.   }

  74.   .chat-voice-word-box {
  75.     height: 38px;
  76.     border-radius: 19px;
  77.     background-color: #F7F8FA;
  78.     text-align: center;
  79.   }

  80.   .chat-voice-word {
  81.     height: 38px;
  82.     line-height: 38px;
  83.     text-align: center;
  84.   }
  85. </style>
复制代码



380
帖子
4
勋章
6
Y币
android 还是 iOS?
38
帖子
4
勋章
1万+
Y币
ios13.5 ,iphone xs max
28
帖子
1
勋章
1万+
Y币
注意页面 A 和 B 的大小,不要相互挤占了,我看你代码中没有为 frame 设置高度。
您需要登录后才可以回帖 登录

本版积分规则