這篇文章主要介紹了微信小程序form組件詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下
form表單組件 是提交form內(nèi)的所有選中屬性的值,注意每個(gè)form表單內(nèi)的組件都必須有name屬性指定否則提交不上去,button中的type兩個(gè)submit,reset屬性分別對應(yīng)form的兩個(gè)事件
主要屬性:
wxml
<form bindsubmit="listenFormSubmit" bindreser="listenFormReser" > <checkbox-group name="checkbox" bindchange="listenerCheckbox"> <label style="display: flex" wx:for-items="{{items}}"> <checkbox value="{{item.name}}"/>{{item.value}} </label> </checkbox-group> <!--button formType屬性兩個(gè)可選值submit, reset分別會觸發(fā)form的submit,reser事件 --> <button formType="submit" type="primary">提交</button> <button formType="reset" type="warn">重置</button> </form>
登錄后復(fù)制
js
Page({ /** * 初始化數(shù)據(jù) */ data:{ items: [ {name: 'JAVA', value: 'Android', checked: 'true'}, {name: 'Object-C', value: 'IOS'}, {name: 'JSX', value: 'ReactNative'}, {name: 'JS', value: 'wechat'}, {name: 'Python', value: 'Web'} ] }, listenCheckboxChange: function() { console.log(e.detail.value); }, onLoad:function(options){ // 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù) } })
登錄后復(fù)制
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)!
相關(guān)推薦:
以上就是微信小程序之form組件的介紹的詳細(xì)內(nèi)容,更多請關(guān)注有卡有網(wǎng)。