Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]: Calendar 日期区间选择问题 #705

Closed
1 of 2 tasks
LOADINGG opened this issue Mar 8, 2024 · 3 comments
Closed
1 of 2 tasks

🐛 [Bug]: Calendar 日期区间选择问题 #705

LOADINGG opened this issue Mar 8, 2024 · 3 comments

Comments

@LOADINGG
Copy link

LOADINGG commented Mar 8, 2024

Which React Vant packages are impacted?

  • react-vant (React Vant core)
  • react-vant-icons(React Vant Icon)

What version of React Vant are you using?

^3.3.1

Reproduce live demo(codesandebox or stackblitz)?

No response

Descripition

Calendar 做日期区间选择,绑定onSelect事件,会默认自己选择节日日期到当日。
日历

@3lang3
Copy link
Owner

3lang3 commented Mar 15, 2024

无法复现,方便提供最小复现代码demo吗

@LOADINGG
Copy link
Author

`const [date, setDate] = useState('2014-03-01~2024-03-15')

const dateConfirm = (e) => {
setDate(${dayjs(e[0]).format('YYYY-MM-DD')}~${dayjs(e[1]).format('YYYY-MM-DD')})
}

return (
<>
已选择的时间:{date}

	<Calendar
		visible={true}
		type='range'
		minDate={new Date('2014/03/01')}
		maxDate={new Date()}
		color="#2D83E8"
		onSelect={(e) => dateConfirm(e)}
		showConfirm={false}
		maxRange={31}
	></Calendar>
</>

);`

@3lang3
Copy link
Owner

3lang3 commented Mar 15, 2024

const today = new Date()
const tommorow = new Date(today.getTime() + 24 * 60 * 60 * 1000)

const [date, setDate] = useState([today, tommorow])

return (
<Calendar type='range' value={value} onSelect={(v) => setValue(v)} />
)

@3lang3 3lang3 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants