We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
5.34.0
Others
No response
由于time的初始值设为了['2024','xx','xx','xx'],代码中!column.some(item => item.value === value)用了严格等于,导致触发了onChange. 考虑换成==吗
==
useIsomorphicLayoutEffect(() => { if (column.length === 0) { if (value !== null) { onSelect(null); } } else { if (!column.some(item => item.value === value)) { // 这里 const firstItem = column[0]; onSelect(firstItem.value); } } }, [column, value]);
import React, { useState, useMemo } from "react"; import { Button, PickerView, Popup } from "antd-mobile"; import _ from "lodash"; import dayjs from "dayjs"; const deafultTimeColumns = [ _.range(2000, 2024).map((item) => ({ label: `${item}年`, value: item })), _.range(1, 13).map((item) => ({ label: `${item}月`, value: item })), _.range(1, 32).map((item) => ({ label: `${item}日`, value: item })), _.range(0, 24).map((item) => ({ label: `${item}时`, value: item })), ]; export default function App() { const [open, setOpen] = useState(false); const [time, setTime] = useState(dayjs().format("YYYY-MM-DD-HH").split("-")); const timeColumns = useMemo(() => { const daysInMonth = dayjs(`${time[0]}-${time[1]}`).daysInMonth(); const newColumns = [...deafultTimeColumns]; newColumns[2] = _.range(1, daysInMonth + 1).map((item) => ({ label: `${item}日`, value: item, })); return newColumns; }, [time]); return ( <div className="App"> <h1>Hello Antd Mobile</h1> <Button onClick={() => { setOpen(true); }} > 打开 </Button> <Popup visible={open}> <PickerView columns={timeColumns} value={time} onChange={(val, extend) => { setTime(val); console.log("onChange", val, extend.items); }} /> </Popup> </div> ); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Version of antd-mobile
5.34.0
Operating system and its version
Others
Browser and its version
No response
Sandbox to reproduce
No response
What happened?
由于time的初始值设为了['2024','xx','xx','xx'],代码中!column.some(item => item.value === value)用了严格等于,导致触发了onChange.
考虑换成
==
吗Relevant log output
The text was updated successfully, but these errors were encountered: