微信小程序 form組件詳解及簡(jiǎn)單實(shí)例
相關(guān)文章:
將表單內(nèi)的用戶輸入的switch input checkbox slider radio picker 提交
當(dāng)點(diǎn)擊 <form/> 表單中 formType 為 submit 的 <button/> 組件時(shí),會(huì)將表單組件中的 value 值進(jìn)行提交,需要在表單組件中加上 name 來作為 key。
| 屬性名 | 類型 | 說明 |
|---|---|---|
| report-submit | Boolean | 是否返回formId用于發(fā)送模板消息 |
| bindsubmit | EventHandle | 攜帶form中的數(shù)據(jù)觸發(fā)submit事件,event.detail = { value : {"name":"value"} , formId:"" } |
| bindreset | EventHandle | 表單重置時(shí)會(huì)觸發(fā)reset事件 |
示例代碼:
<form bindsubmit="formSubmit" bindreset="formReset"> <view class="section section_gap"> <view class="section__title">switch</view> <switch name="switch"/> </view> <view class="section section_gap"> <view class="section__title">slider</view> <slider name="slider" show-value ></slider> </view> <view class="section"> <view class="section__title">input</view> <input name="input" placeholder="please input here" /> </view> <view class="section section_gap"> <view class="section__title">radio</view> <radio-group name="radio-group"> <label><radio value="radio1"/>radio1</label> <label><radio value="radio2"/>radio2</label> </radio-group> </view> <view class="section section_gap"> <view class="section__title">checkbox</view> <checkbox-group name="checkbox"> <label><checkbox value="checkbox1"/>checkbox1</label> <label><checkbox value="checkbox2"/>checkbox2</label> </checkbox-group> </view> <view class="btn-area"> <button formType="submit">Submit</button> <button formType="reset">Reset</button> </view> </form>
Page({
formSubmit: function(e) {
console.log('form發(fā)生了submit事件,攜帶數(shù)據(jù)為:', e.detail.value)
},
formReset: function() {
console.log('form發(fā)生了reset事件')
}
})
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
js前端表單數(shù)據(jù)處理表單數(shù)據(jù)校驗(yàn)
這篇文章主要為大家介紹了js前端表單數(shù)據(jù)處理表單數(shù)據(jù)校驗(yàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
微信小程序(應(yīng)用號(hào))開發(fā)新聞客戶端實(shí)例
這篇文章主要介紹了微信小程序(應(yīng)用號(hào))開發(fā)新聞客戶端實(shí)例的相關(guān)資料,需要的朋友可以參考下2016-10-10
微信小程序 setData使用方法及常用錯(cuò)誤解決辦法
這篇文章主要介紹了微信小程序 setData使用方法及常用錯(cuò)誤解決辦法的相關(guān)資料,需要的朋友可以參考下2017-05-05
微信小程序 中wx.chooseAddress(OBJECT)實(shí)例詳解
這篇文章主要介紹了微信小程序 中wx.chooseAddress(OBJECT)實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-03-03
微信小程序動(dòng)態(tài)的加載數(shù)據(jù)實(shí)例代碼
這篇文章主要介紹了 微信小程序動(dòng)態(tài)的加載數(shù)據(jù)實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2017-04-04


