微信小程序实例:move事件导致navigator组件和tap事件无效
来源:互联网 发布:mac 无法开机无法充电 编辑:程序博客网 时间:2024/05/20 11:47
今天,微信小程序终于发布了,激动的同时也在加紧最后公司项目的测试,结果发现了一个问题,就是在使用catch绑定move事件的时候,无法触发navigator组件的url和tap事件。测试如下:
test.wxml::
<view class="flex-h" style="width: 750rpx; height: 200rpx; border: solid 1px green;" catchtouchstart="slideTouchStart" catchtouchmove="slideTouchMove" catchtouchend="slideTouchEnd"> <view class="item" bindtap="testTap" style="width: 100rpx; height: 100rpx; border: solid 1px red;"> 1111 </view> <view class="item" catchtap="testTap" style="width: 100rpx; height: 100rpx; border: solid 1px red;"> 222 </view> <view class="item" catchtap="testTap" style="width: 100rpx; height: 100rpx; border: solid 1px red;"> 333 </view> <navigator url="/pages/index/index" style="width: 100rpx; height: 100rpx; border: solid 1px red;"> <view>nnnn fjlsdjfslfjs dljfslfjsl sdlfjdslkf </view> </navigator></view><!--或者把tap和navigator组件和绑定move事件的view组件对调也没有反应--><view class="flex-h" style="width: 750rpx; height: 200rpx; border: solid 1px green;" catchtap="testTap"> <view class="item" style="width: 100rpx; height: 100rpx; border: solid 1px red;" catchtouchstart="slideTouchStart" catchtouchmove="slideTouchMove" catchtouchend="slideTouchEnd"> 1111 </view></view>
test.js::
var App = getApp();Page({ data: {}, slideTouchStart: function (e) { console.log('111') }, slideTouchMove: function (e) { console.log('222') }, slideTouchEnd: function (e) {console.log('333') }, testTap: function(e){ console.log('-1-1-1-10'); }, onLoad: function (options) { var that = this; }});
不晓得为啥move事件会导致这样的结果,按照html层级关系,我在内层写了tap事件应该是先触发了tap,然后在冒泡上去触发move事件,可是不管我tap事件是用catch还是bind绑定都无法触发,后来我把movestart事件用bind绑定了,竟然奇迹般的触发了内层的tap事件和navigator组件。不晓得是不是微信bug!!
最后演示如下:
然而,在指定了bindmovestart事件后的测试过程发现navigator组件的地址明明是正确的但是就是无法触发跳转操作,经测试猜测是不是目录结构的问题。为了证明,做了如下测试:
这里我的pages目录有的是2级的有的是3级的,比如pages/index/index是2级的,pages/search/city/city是3级的,我当前测试的目录是pages/test/test。结果发现无法跳转index页面,可以跳转city页面。
为了进一步证实,我又跑去city页面进行测试跳转到index页面,结果发现也是无法跳转的,但是能跳转到text页面。
最后,突然想到我的首页,很多图片是Failed to load image...not found状态,导致编译的时候控制台会出现编译出错信息,而我的city页面和test页面是没有图片,并没有报错,因此能正常跳转。可是我找不到的图片也都指定了默认图片了。还会这样,真的是很奇葩呢!!
**********************************************************************************************************************
然而,今天我又去翻看了下navigator组件,发现redirect要移除了,增加了open-type类型,新增跳转tabBar页面的制定类型switchTab。然后我又去查看navigatorTo接口和redirectTo接口发现官方文档给出如下提示:
这样的话,是不是说明navigator组件也需要制定open-type=switchTab的情况下才能跳转呢??经测试证明确实是这样的,如果是跳转tabBar页面就需要强制制定open-type类型,页面之间就能正常跳转了。
**********************************************************************************************************************
【最后结贴2017-01-13】
- 微信小程序实例:move事件导致navigator组件和tap事件无效
- UITextFieldDelegate和tap事件
- 微信小程序 navigator组件
- tap 和click 事件区别
- tap 和click 事件区别
- 微信小程序实例:image组件的binderror事件处理
- 微信小程序,关于navigator子元素绑定事件,阻止navigator跳转
- 微信小程序-双击长按触发longtap事件时同时触发tap事件解决办法
- 兼容tap事件
- 封装tap事件
- (zepto插件使用)click、tap无效又能实现点击事件小窍门
- sencha label 捕捉tap事件
- tap点击事件范围限制
- tap事件不响应问题
- mui的单击事件 tap
- zepto tap事件阻止事件冒泡
- 布局的move事件
- 微信小程序--地图regionchange事件频繁触发导致崩溃
- 实现一个选择排序程序,排序整型数组
- JavaScript 面向对象介绍
- select重置
- vs2013编译win-32位下的libevent-2.0.21-stable,debug版本
- IOS的Cookie之网页身份认证与Session的追踪
- 微信小程序实例:move事件导致navigator组件和tap事件无效
- poj Children of the Candy Corn(BFS+DFS)
- apache 配置 httpd-vhost.conf 。VirtualHost 配置更改域名,端口 。 无法访问 localhost
- MyBatis动态传入表名,字段名参数的解决办法
- JAVA 枚举类型 根据代码得到中文
- PAT乙级1027
- UIWebView保存图片
- Spring面试,IoC和AOP的理解
- 2016年第七届蓝桥杯C/C++程序设计_编程题9题_交换瓶子