我正在使用 Next.JS 应用程序路由系统。
我创建了一条结构如下的动态路线pages/[country]/[language]/index.js。
还有一个带有结构的静态路由pages/cz/cz/index.js。
然后出现问题,我在静态页面上,并尝试通过Link组件导航来访问静态路由内容,在我的情况下应该转到主页并重新加载同一页面,而不是呈现动态路由内容。
<Link to="/">就我而言,链接只是两个路线主页的简单导航。但问题可能在于如何为预定义和动态路由设置 index.js 文件。
捷克/捷克/index.js
export { default } from '../../../components/HomePage/';
const { getStaticProps } = createRoute({
path: '/',
locale: 'cs',
});
export { getStaticProps };
Run Code Online (Sandbox Code Playgroud)
[国家/地区]/[语言]/index.js
export { default } from '../../../components/HomePage/v2';
const { getStaticPaths, getStaticProps } = createRoute({
path: '/',
exclude: ['cs'],
otherLocales: ['cs'],
});
export { getStaticPaths, getStaticProps };
Run Code Online (Sandbox Code Playgroud)
创建路由
export default function createRoute({
path,
otherLocales,
getPathParams,
locale,
} = {}) {
const locales …Run Code Online (Sandbox Code Playgroud)