赞
踩
data:{} 页面的初始数据;
data的后面可以写wxml中绑定的事件,如showPopup() {};
onLoad:function(options){} 监听页面加载;
onShow:function(){} 监听页面显示;
onHide:function(){} 监听页面隐藏;
onUnload:function(){} 监听页面卸载;
bindtap和catchtap都是当用户点击该组件的时候会在该页面对应的Page中找到相应的事件处理函数。但是bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡。
<view id="outer" bindtap="handleTap1"> outer view <view id="middle" catchtap="handleTap2"> middle view <view id="inner" bindtap="handleTap3"> inner view </view> </view> </view> Page({ handleTap1:function(event){ //点击输出outer view bindtap console.log("outer view bindtap") }, handleTap2: function (event) { //点击输出middle view console.log("middle view catchtap") }, handleTap3: function (event) { //点击输出inner view bindtap middle view catchtap console.log("inner view bindtap") }, }) <view id="outer" bindtap="handleTap1"> outer view <view id="middle" bindtap="handleTap2"> middle view <view id="inner" bindtap="handleTap3"> inner view </view> </view> </view> Page({ handleTap1:function(event){ //点击输出outer view bindtap console.log("outer view bindtap") }, handleTap2: function (event) { //点击输出outer view bindtap middle view console.log("middle view catchtap") }, handleTap3: function (event) { //点击输出outer view bindtap inner view bindtap middle view catchtap console.log("inner view bindtap") }, })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。