问答详情
源自:-

form提交的值为空?

没有报错,请求是成功的,后台也没有报错,就是提交的表单数据都是空,数据库有这一条数据,但也是空值。为什么?

--------------------------

.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>


提问者:quantum_y 2018-12-21 13:07

个回答