form提交的值為空?
沒有報錯,請求是成功的,后臺也沒有報錯,就是提交的表單數(shù)據(jù)都是空,數(shù)據(jù)庫有這一條數(shù)據(jù),但也是空值。為什么?
--------------------------
.js
--------------------------
formSubmit: function(e) {
if (e.detail.value.name.length == 0 || e.detail.value.houseId.length == 0) {
wx.showToast({
title: '姓名或房間號不能為空',
icon: 'loading',
duration: 1500
})
} else {
var that = this;
var url = that.data.addUrl;
var formData = e.detail.value;
console.log(formData)
wx.request({
url: url,
data: {
// id:e.target.value.id,
household:e.target.value
},
dataType: JSON,
method: 'POST',
header: {
'content-type': 'application/json' // 默認值
},
complete: function(res) {
console.log("success")
wx.redirectTo({
url: '/pages/info/info',
})
}
})
}
}
-----------------------------------------------------------------------
.wxml
-----------------------------------------------------------------------
<view class="container">
<form bindsubmit="formSubmit" bindreset="formReset">
<input type='text' name="id" class='id' value="{{id}}"></input>
<view class="row">
<text>姓名:</text>
<input type="text" name="name" placeholder="姓名" value="{{name}}" required/>
</view>
<view class="row">
<text>房間號</text>
<input type="text" name="houseId" placeholder="房間號" value="{{houseId}}" />
</view>
<view class="row">
<button type="primary" form-type="submit">提交</button>
<button type="primary" form-type="reset">清空</button>
</view>
</form>
</view>
2018-12-21
@xiangzepro