index.js:235 uView提示:maxDate不能小于当前时间

组件不合理的提示。我就是不想让他maxDate选择未来时间。

需求:用uview的calendar做一个时间段的选择,当设置maxDate为今天,遇到这个无理的提示。

1、找到calendar组件源码提示位置

在这里插入图片描述

2、注释掉这段代码

在这里插入图片描述

3、看效果

在这里插入图片描述

我的代码

<template>
	<view class="container">
		<view class="top">
			<view class="timebox" @click="show=true">
				<view class="date">
					{{ showData }}
				</view>
				<u-icon bold name="calendar" color="#F5DA43" size="44"></u-icon>
			</view>
		</view>
		<u-calendar 
			:show="show" 
			mode="range" 
			@confirm="confirm" 
			@close="close" 
			:defaultDate="defaultDate" 
			allowSameDay 
			:minDate="chooseRange[0]" 
			:maxDate="chooseRange[1]" 
			monthNum="10"
			:rowHeight="110" 
			closeOnClickOverlay round="10" >
			</u-calendar>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				show:true,
				dateArr:[],
				defaultDate:""
			}
		},
		onLoad(){
			// 默认查昨天到今天
			this.defaultDate = [this.$dayjs().subtract(1,'day').format("YYYY-MM-DD"),this.$dayjs().format("YYYY-MM-DD")];
			this.dateArr = [this.$dayjs().subtract(1,'day').format("YYYY-MM-DD"),this.$dayjs().format("YYYY-MM-DD")];
		},
		computed:{
			// 过滤显示时间
			showData(){
				return  this.$dayjs(this.dateArr[0]).format("YYYY/MM/DD")+'-'+this.$dayjs(this.dateArr[this.dateArr.length-1]).format("YYYY/MM/DD");
			},
			// 可选时间范围
			chooseRange(){
				return [this.$dayjs().subtract(1,'month').format("YYYY-MM-DD"),this.$dayjs().format("YYYY-MM-DD")]
			}
		},
		methods:{
			confirm(dateArr){
				this.dateArr = [dateArr[0],dateArr[dateArr.length-1]];
				console.log(this.dateArr); //  获取到我想要的两个日期
				this.show=false;
			},
			close(){
				this.show=false;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		margin: 30rpx;
		padding:20rpx;
		box-sizing: border-box;
		background: #fff;
	}
	.top{
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		.label{
			margin-right: 20rpx;
		}
		.timebox{
			padding:6rpx 16rpx;
			color:#999;
			display: flex;
			align-items: center;
			border: 1rpx solid #999;
			border-radius: 4rpx;
			.date{
				margin-right: 10rpx;
				font-size:26rpx;
			}
		}
	}
</style>
  • 21
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
index.js:4130 Cannot find module './uni_modules/uview-ui/components/u-navbar/u-navbar.vue' Qld0 @ index.js:4130 __webpack_require__ @ index.js:854 fn @ index.js:151 JLrY @ index.js:1430 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ kyBj:2 kyBj @ index.js:4897 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ main.js:36 Tglg @ index.js:4322 __webpack_require__ @ index.js:854 fn @ index.js:151 1 @ index.js:1057 __webpack_require__ @ index.js:854 checkDeferredModules @ index.js:46 (anonymous) @ index.js:994 (anonymous) @ index.js:997 index.js:4131 1. 排查组件名称拼写是否正确 Qld0 @ index.js:4131 __webpack_require__ @ index.js:854 fn @ index.js:151 JLrY @ index.js:1430 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ kyBj:2 kyBj @ index.js:4897 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ main.js:36 Tglg @ index.js:4322 __webpack_require__ @ index.js:854 fn @ index.js:151 1 @ index.js:1057 __webpack_require__ @ index.js:854 checkDeferredModules @ index.js:46 (anonymous) @ index.js:994 (anonymous) @ index.js:997 index.js:4132 2. 排查组件是否符合 easycom 规范,文档:https://uniapp.dcloud.net.cn/collocation/pages?id=easycom Qld0 @ index.js:4132 __webpack_require__ @ index.js:854 fn @ index.js:151 JLrY @ index.js:1430 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ kyBj:2 kyBj @ index.js:4897 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ main.js:36 Tglg @ index.js:4322 __webpack_require__ @ index.js:854 fn @ index.js:151 1 @ index.js:1057 __webpack_require__ @ index.js:854 checkDeferredModules @ index.js:46 (anonymous) @ index.js:994 (anonymous) @ index.js:997 index.js:4135 3. 若组件不符合 easycom 规范,需手动引入,并在 components 中注册该组件 Qld0 @ index.js:4135 __webpack_require__ @ index.js:854 fn @ index.js:151 JLrY @ index.js:1430 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ kyBj:2 kyBj @ index.js:4897 __webpack_require__ @ index.js:854 fn @ index.js:151 eval @ main.js:36 Tglg @ index.js:4322 __webpack_require__ @ index.js:854 fn @ index.js:151 1 @ index.js:1057 __webpack_require__ @ index.js:854 checkDeferredModules @ index.js:46 (anonymous) @ index.js:994 (anonymous) @ index.js:997 Request.js:53 Uncaught TypeError: f is not a function at Request.setConfig (Request.js:53:23) at Object.install (http.interceptor.js:4:24) at Vue.use (chunk-vendors.js:7461:22) at eval (main.js:160:5) at Object.Tglg (index.js:4322:1) at __webpack_require__ (index.js:854:30) at fn (index.js:151:20) at 1 (index.js:1057:18) at __webpack_require__ (index.js:854:30) at checkDeferredModules (index.js:46:23)解决
07-14

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值