86. 小程序中的form表单提交
js
formSubmit(e){
const vm = this
let postData = e.detail.value;
postData.location = vm.data.region.join('')
postData.user_id = 1
wx.showLoading()
addAgent(postData)
.then(res => {
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
wx.showToast({
title: err.msg,
icon:'none'
})
})
}
wxml
<form bindsubmit="formSubmit">
<view class="m-info">
<view class="item">
<view class="title">姓名</view>
<view class="input">
<input name="user_name" type="text" placeholder="请输入经销商姓名" />
</view>
</view>
...
</view>
<button class="m-btn" form-type="submit">确认</button>
</form>