微信小程序常用控件
1.弹窗,确认并跳转页面
wx.showModal({
title: '提示:',
content: '非法访问,请重新找回密码',
//取消按钮不显示
showCancel: false,
//确认按钮
success: function (res) {
wx.navigateTo({
url: 'A' //跳转的页面
})
}
})
2.获取上一页传过来的值
在onLoad中赋值 options 一定要填上
onLoad: function (options) {
//将传的值 赋值到 data数据中
this.setData({
username: options.username
})
}
3.JS页面 data中数组保存与应用
在js中保存数组需要使用{ 名:值,名:‘值’ }的方式
data: {
Bcode: { bgcolor: '#00CCFF', disable:false},
},
修改数组中的值
this.setData({
'Bcode.bgcolor':'glay',
'Bcode.disable':true,
})
在wxml中的渲染
<view >
<button class="tel_Bcode" bindtap='getcode' style="background:{{Bcode.bgcolor}};" disabled="{{Bcode.disable}}" >
获取验证码
</button>
</view>
4.获取 输入框 中的内容
wxml:
<input type='text' bindinput="pwd1" />
此处使用 bindinput
,使用 bindtap
无效
js:
pwd1: function (e){
console.log(e.detail.value)
}
此处的 e 也可以使用 event
小白一个不定时更新,如有错误欢迎指出!