hash to id
This commit is contained in:
parent
93f572a0b3
commit
46bb4617d4
2 changed files with 16 additions and 1 deletions
|
|
@ -8,6 +8,21 @@ export function Page() {
|
|||
const [age, setAge] = useState<number>(0);
|
||||
const [post, setPost] = useState<any>({});
|
||||
|
||||
useEffect(() => {
|
||||
const scrollToHash = () => {
|
||||
const hash = window.location.hash.substring(1);
|
||||
if (hash) {
|
||||
const element = document.getElementById(hash);
|
||||
if (element) {
|
||||
setTimeout(() => {
|
||||
element.scrollIntoView({ behavior: "smooth" });
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
};
|
||||
scrollToHash();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// 나이 계산
|
||||
const referenceDate = new Date(2010, 10, 8); // 2010년 11월 8일 (0-indexed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue