- website: 单页落地(愿景、架构、路径、团队范式、生命周期) - nginx:alpine 镜像与 docker-compose(端口 8888) Made-with: Cursor
17 lines
508 B
JavaScript
17 lines
508 B
JavaScript
(() => {
|
|
const year = document.querySelector("[data-year]");
|
|
if (year) year.textContent = String(new Date().getFullYear());
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
|
|
anchor.addEventListener("click", (e) => {
|
|
const id = anchor.getAttribute("href");
|
|
if (!id || id === "#") return;
|
|
const el = document.querySelector(id);
|
|
if (el) {
|
|
e.preventDefault();
|
|
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
}
|
|
});
|
|
});
|
|
})();
|