微信小程序 input表單與redio及下拉列表的使用實(shí)例
微信小程序 input表單與redio及下拉列表的使用實(shí)例
一個(gè)簡(jiǎn)單的預(yù)約類型的表單,效果

主要代碼:
<form bindsubmit="bindSave">
<view class="form-box">
<view class="row-wrap">
<view class="label">聯(lián)系人</view>
<view class="label-right">
<input name="userName" class="input" type="text" placeholder="姓名" value="{{addressData.userName}}" />
</view>
</view>
<view class="row-wrap">
<view class="label">性別</view>
<radio-group class="radio-group" bindchange="radioChange">
<label class="radio" wx:for="{{items}}">
<radio value="{{item.name}}" checked="{{item.checked}}" />{{item.value}}
</label>
</radio-group>
</view>
<view class="row-wrap">
<view class="label">手機(jī)號(hào)碼</view>
<view class="label-right">
<input name="mobile" class="input" maxlength="11" type="number" placeholder="11位手機(jī)號(hào)碼" value="{{addressData.mobile}}" />
</view>
</view>
<view class="row-wrap">
<view class="label">預(yù)約項(xiàng)目</view>
<picker bindchange="bindCasPickerChange" value="{{casIndex1}}" range="{{casArray}}">
<view>
<text>{{casArray[casIndex]}}</text>
</view>
</picker>
</view>
</view>
<view class="btn-tyc">
<button size="mini" bindtap="tapAddCart" class="submit" type="primary" formType="submit">提交預(yù)約</button>
</view>
<button size="mini" bindtap="tlp_phone" class="phone" type="primary">撥打電話</button>
</form>
.js文件
data: {
nickName: "",
avatarUrl: "",
casArray: ['雙眼皮', 'TBM', '隆胸', '減肥', 'qita'],
userName: '',
mobile: '',
Gender: 'female',
casIndex: 0,
items: [
{ name: 'male', value: '男' },
{ name: 'female', value: '女', checked: 'true' },
]
},
radioChange: function (e) {
console.log('值:', e.detail.value)
this.setData({
Gender: e.detail.value
})
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面加載
*/
bindCasPickerChange: function (e) {
console.log(this.data.casArray);
console.log('下拉選擇的是', this.data.casArray[e.detail.value])
this.setData({
casIndex: e.detail.value
})
},
具體的表單樣式可以自己調(diào)整,wxss樣式文件代碼不寫了
參照官方文檔form組件
https://mp.weixin.qq.com/debug/wxadoc/dev/component/form.html
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- 微信小程序中form 表單提交和取值實(shí)例詳解
- 微信小程序 PHP后端form表單提交實(shí)例詳解
- 微信小程序 表單Form實(shí)例詳解(附源碼)
- 微信小程序?qū)崿F(xiàn)表單校驗(yàn)功能
- 微信小程序簡(jiǎn)單實(shí)現(xiàn)form表單獲取輸入數(shù)據(jù)功能示例
- 微信小程序表單驗(yàn)證功能完整實(shí)例
- 微信小程序表單驗(yàn)證form提交錯(cuò)誤提示效果
- 微信小程序表單彈窗實(shí)例
- 微信小程序使用form表單獲取輸入框數(shù)據(jù)的實(shí)例代碼
- 微信小程序?qū)W習(xí)筆記之表單提交與PHP后臺(tái)數(shù)據(jù)交互處理圖文詳解
- 微信小程序bindinput與bindsubmit的區(qū)別實(shí)例分析
相關(guān)文章
定時(shí)器在頁(yè)面最小化時(shí)不執(zhí)行實(shí)現(xiàn)示例
這篇文章主要為大家介紹了定時(shí)器在頁(yè)面最小化時(shí)不執(zhí)行的實(shí)現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
arrify 轉(zhuǎn)數(shù)組實(shí)現(xiàn)示例源碼解析
這篇文章主要為大家介紹了arrify 轉(zhuǎn)數(shù)組實(shí)現(xiàn)示例源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
詳解如何使用mock.js實(shí)現(xiàn)接口測(cè)試的自動(dòng)化
這篇文章主要為大家介紹了如何使用mock.js實(shí)現(xiàn)接口測(cè)試的自動(dòng)化詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06
JS實(shí)現(xiàn)layui?table篩選框記憶功能
這篇文章主要介紹了JS實(shí)現(xiàn)layui?table篩選框記憶功能,本案例放入本地緩存的方式,使用MutationObserver實(shí)現(xiàn)監(jiān)控點(diǎn)擊事件,需要的朋友可以參考下2022-01-01

