微信小程序 form組件詳解
表單:
將組件內(nèi)的用戶輸入的<switch/> <input/> <checkbox/> <slider/> <radio/> <picker/> 提交
主要屬性:
效果圖:
ml:
<!--頭像--> <view style="display:flex;justify-content: center;"> <image style="width:130rpx;height:130rpx;border-radius:50%;margin-top:10%;" src="../../image/logo.jpg"> </image> </view> <!-- form表單組件 是提交form內(nèi)的所有選中屬性的值, 注意每個(gè)form表單內(nèi)的組件都必須有name屬性指定否則提交不上去, button中的type兩個(gè)submit,reset屬性分別對(duì)應(yīng)form的兩個(gè)事件 --> <form bindsubmit="listenFormSubmit" bindreser="listenFormReser" > <!--用戶名與密碼--> <View class="inputView"> <input class="input" name="username" type="number" placeholder="請(qǐng)輸入賬號(hào)" placeholder-style="color: gray"> </input> </View> <view class="inputView"> <input class="input" name="password" password="true" placeholder="請(qǐng)輸入密碼" placeholder-style="color: gray"/> </view> <!--登錄用戶類型--> <View style="display:flex;justify-content: center;margin-top:10px;"> <radio-group name="radio-group" bindchange="radioChange"> <label> <radio value="manager" checked="true"/>管理員 </label> <label> <radio value="tearch" checked="true"/>老師 </label> <label> <radio value="student" checked="true"/>學(xué)生 </label> </radio-group> <!--忘記密碼--> <label> <switch name="switch" type="checkbox" checked bindchange="switch1Change" style="margin-left:20px;"/> <Text style="font-size: 14px;padding-left:5px;">忘記密碼?</Text> </label> </View> <!--button formType屬性兩個(gè)可選值submit, reset分別會(huì)觸發(fā)form的bindsubmit,bindreser事件 --> <button formType="submit" type="primary" style="margin-top:10px;">提交</button> <button formType="reset" type="warn" style="margin-top:10px;">重置</button> </form>
ss:
.input{ padding-left: 10px; height: 44px; } .inputView{ /*邊界:大小1px, 為固體,為綠色*/ border: 1px solid green; /*邊界角的弧度*/ border-radius: 10px; margin-left: 5px; margin-right: 5px; margin-top: 15px; }
js:
復(fù)制代碼
Page({ data:{ // text:"這是一個(gè)頁面" }, //點(diǎn)擊提交 listenFormSubmit:function(e){ console.log('listenFormSubmit=',e.detail.value) }, //點(diǎn)擊重置 listenFormReser:function(e){ console.log('listenFormReser=',e.detail.value) }, //點(diǎn)擊忘記密碼 switch1Change:function(e){ console.log('switch1Change=',e.detail.value) }, //當(dāng)選中某一個(gè)的時(shí)候回調(diào)該函數(shù)。e.detail.value:獲取選中某個(gè)radio的value radioChange: function(e) { console.log('radio發(fā)生change事件,攜帶value值為:', e.detail.value) } })
注意:
form表單組件 是提交form內(nèi)的所有選中屬性的值,
注意每個(gè)form表單內(nèi)的組件都必須有name屬性指定否則提交不上去,
button中的type兩個(gè)submit,reset屬性分別對(duì)應(yīng)form的兩個(gè)事件
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Web?Animations?API實(shí)現(xiàn)一個(gè)精確計(jì)時(shí)的時(shí)鐘示例
這篇文章主要為大家介紹了Web?Animations?API實(shí)現(xiàn)一個(gè)精確計(jì)時(shí)的時(shí)鐘示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07PerformanceObserver自動(dòng)獲取首屏?xí)r間實(shí)現(xiàn)示例
今天給大家介紹一個(gè)非常好用的瀏覽器api:?PerformanceObserver?,?我們可以用它來獲取首屏、白屏的時(shí)間,就不用再麻煩地手動(dòng)去計(jì)算了2022-07-07前端項(xiàng)目中監(jiān)聽localStorage的變化
這篇文章主要為大家介紹了前端項(xiàng)目中監(jiān)聽localStorage的變化的解決思路詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06微信小程序 視圖層(xx.xml)和邏輯層(xx.js)詳細(xì)介紹
這篇文章主要介紹了微信小程序 視圖層(xx.xml)和邏輯層(xx.js)詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2016-10-10微信小程序Server端環(huán)境配置詳解(SSL, Nginx HTTPS,TLS 1.2 升級(jí))
這篇文章主要介紹了微信小程序Server端環(huán)境配置詳解(SSL, Nginx HTTPS,TLS 1.2 升級(jí))的相關(guān)資料,需要的朋友可以參考下2017-01-01