uView框架中DatetimePicker选择器设置默认值

需求是页面显示的哪天日期 点开就是哪天的日期

 uview的文档有个defaultIndex属性设置各列的默认索引,但是使用发现无效果

解决方案:使用innerValue

1.给选择器添加ref

	<u-datetime-picker :maxDate='maxDate' closeOnClickOverlay @close='yearmonthshowClose' immediateChange
			 ref="picker" @cancel='yearmonthshowClose' @confirm='yearmonthshowSure'
			:show="yearmonthshow" v-model="yearmonthvalue" mode="date">
		</u-datetime-picker>

 2.在点击显示日期弹框的地方使用

	//点击显示时间选择器
			yearmonthshowBtn() {
				this.yearmonthshow = true
             //new Date(this.endDate).getTime()为你需要在选择器上显示的时间戳
			    this.$refs.picker.innerValue=new Date(this.endDate).getTime()	
			}

猜你喜欢

转载自blog.csdn.net/weixin_69666355/article/details/131372719