wxml
<form bindsubmit="formSubmit">
<view class="section">
<view class="section-title">生日</view>
<view class="display" wx:if="{{changeOrSubmit}}" style="color: {{birthday ? '#000' : '#666'}}">{{birthday || '未设置出生日期'}}</view>
<picker mode="date" start="1990-09-01" end="2020-09-01" data-type="birthday" bindchange="userInput" value="{{birthday}}" wx:if="{{!changeOrSubmit}}">
<view class="picker" style="color: {{birthday ? '#000' : '#888'}};">{{birthday || '请输入出生日期'}}</view>
</picker>
</view>
<view class="btn-area">
<button formType="submit" type="primary">{{changeOrSubmit ? '修改' : '提交'}}</button>
</view>
</form>
js
userInput: function (e) {
console.log(e,"123")
var self = this;
var type = e.currentTarget.dataset.type;
switch (type) {
case 'birthday':
console.log(e.detail.value)
self.setData({ birthday: e.detail.value });
break;
}
}
formSubmit: function (e) {
console.log(e.detail.value)
console.log(app.userInfo,"用户信息")
console.log(e.detail.value.birthday,"生日") undefined
if (!this.data.changeOrSubmit) {
db.collection('userinfo').where({
_id: app.userInfo._id
}).update({
data:
birthday: e.detail.value.birthday,
}
}).then(res=>{
app.userInfo.nickName=this.data.nickName
wx.showModal({
title: '提示',
content: '修改成功',
success: function (res) {
console.log(res)
if (res.confirm) {
console.log('用户点击确定')
}
}
})
})
this.setData({
changeOrSubmit: true
})
} else {
this.setData({
changeOrSubmit: !this.data.changeOrSubmit
});
}
},

form | 微信开放文档
https://developers.weixin.qq.com/miniprogram/dev/component/form.html
你得设置组件的name属性。像你的代码里,picker的name要为birthday