【问题标题】:Routes config on next-routes下一条路线上的路线配置
【发布时间】:2019-02-27 09:59:12
【问题描述】:

在我的项目中,我使用的是 React + Next.js。对于路线,我使用图书馆 next-routes。当您导航嵌套路由 "{category alias}/filter" 时,页面会重新加载。

添加路线 - routes.add ({name: 'products', pattern: '/:noname/filter', page: 'products'})

路线链接 - <Link route="category_alias/filter">Products</ Link>

如何让它在不重新加载的情况下工作?

【问题讨论】:

    标签: react-native routes next.js js-routes


    【解决方案1】:

    我的印象是您仍在使用Link 内的Link 参数

    如果是这样,则切换到使用 Link 对象找到导出下一条路由的文件

    假设您在项目的根目录中有 routes.js 文件:

    然后在pages/test.js这样的路径中

    import React from 'react';
    import { Link } from '../routes';
    
    export default function() {
        return (
            <Link route="/category_alias/filter">
                <a>Testing the microphone</a>
            </Link>
        );
    }
    

    https://github.com/fridays/next-routes#on-the-client

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 1970-01-01
      • 2011-07-10
      相关资源
      最近更新 更多