WeChat アプレット フォーム コンポーネント フォーム
WeChat アプレット フォーム
スイッチ
input
チェックボックス
スライダー
ラジオ
ピッカー
送信 switch
input
checkbox
slider
radio
picker
提交
当点击 <form/>
表单中 formType 为 submit 的 <button/>
<form/>
コンポーネントをクリックすると、フォーム コンポーネントの値が送信され、名前を追加する必要がありますフォームコンポーネントにキーとして追加します。 サンプルコード:
<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发生了submit事件,携带数据为:', e.detail.value) }, formReset: function() { console.log('form发生了reset事件') } })
![form](https://img.php.cn//img.w3cschool.cn/attachments/day_160923/201609231015568331.png)
🎜