そのようなコンポーネントがあります。
const Milestone = props => {
const { path, disabled, index, ...rest } = props;
if (disabled) return <MilestoneCheck disabled />;
return (
<Link href={path} passHref>
<a>
<MilestoneCheck {...rest} />
</a>
</Link>
);
};
_
[リンク]をクリックすると、次のページに移動して[戻る]ボタンをクリックして[戻る]ボタンをクリックすると、ページは最後のスクロール位置からページにロードされません。ルートの変更に関する「スクロール」方式の追加方法はあまり効率的ではないと感じますが、上部にページを読み込むのに常によりエレガントなソリューションはありますか?
ページ内/レイアウトコンポーネントのインポート次のルータのインポート
import Router from 'next/router';
// you can then hook into there events
Router.onRouteChangeStart = () => {
};
Router.onRouteChangeComplete = () => {
window.scroll({
top: 0,
left: 0,
});
};
Router.onRouteChangeError = () => {
};
const Page = props => {
return <div>{props.children}</div>
}
_