#author("2024-03-11T20:12:01+08:00","default:Admin","Admin")
#author("2024-03-11T20:17:45+08:00","default:Admin","Admin")
[[uni-app]]

&color(red){※前提条件:vue3 的uniapp开发};

#contents

* 问题 [#c8b9c656]
** u-datetime-picker 修改日期显示时间戳的问题 [#b117854c]

#codeprettify{{
<u-datetime-picker :show="show2" v-model="valueBirthday" mode="date" closeOnClickOverlay :formatter="formatter"
@confirm="confirmBirth" @cancel="cancelBirth" @change="changeBirth" @close="closeBirth">
</u-datetime-picker>
}}

解决办法 使用异步

#codeprettify{{
async confirmBirth(e) {
  this.valueBirthday = await uni.$u.timeFormat(e.value, 'yyyy年mm月dd日')
  this.show2 = false
}
}}

**设置最小日期事件 [#c475eaa9]

最多到1970年1月1日,解决办法

#codeprettify{{
[Vue warn]: Invalid prop: type check failed for prop "minDate". Expected Number with value -628502400000, got Date 

found in

---> <DatetimePicker> at uni_modules/uview-ui/components/u-datetime-picker/u-datetime-picker.vue
       at pages/index/regist.vue
}}

注意一定是number 

#codeprettify{{
this.minDate = Number(new Date(1950, 1, 1));
data() {
	return {
		birthdayMin: 0,
		birthdayMax: 0,
	};
},
onReady() {
	this.birthdayMin = Number(new Date(1950, 1, 1));
	this.birthdayMax = Number(new Date(2022, 12, 30));
},
}}

#hr();
Comment:
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS