微信小程序常用控件
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
小白一個不定時更新,如有錯誤歡迎指出!