微信小程序事件 bindtap bindinput代码实例
时间:2021-12-12 11:57:49|栏目:JavaScript代码|点击: 次
一、bindtap事件
在wxml文件里绑定:
<view class='wel-list' bindtap='TZdown'> <image src="/images/welcome_08.png"></image> <text>C语言资料下载</text> </view>
在js文件里相应:
Page({
TZdown: function () {
wx.navigateTo({
url: '../download/download'
});
}
})
二、bindinput事件
wxml文件:
<input type="number" placeholder="请输入手机号" class="inp-holder" maxlength="11" bindinput="getPhone" /> <input type="number" placeholder="请输入验证码" class="inp-holder" maxlength="6" bindinput="getCode" />
js文件:
// 拿到手机号
getPhone: function (e) {
var val = e.detail.value;
this.setData({
telphone: val
});
},
// 拿到验证码
getCode: function (e) {
var val = e.detail.value;
this.setData({
code: val
});
},
上一篇:JS监控关闭浏览器操作的实例详解
栏 目:JavaScript代码
下一篇:window.location的重写及判断location是否被重写
本文标题:微信小程序事件 bindtap bindinput代码实例
本文地址:http://www.codeinn.net/misctech/186654.html






