将下一个js更新到v9后出现链接错误-参数“ url”必须为字符串,而不是未定义

我最近将 nextJs 项目更新到了版本9。我使用 next-routes 包进行类似底部的导出。

const routes = require('next-routes');

module.exports = routes()
    //******************************** structure of routes => {nameOfRoute,pattern  of route,page name inside pages folder } ************
    .add('homepage','/','index')
    // **************************** Profile routes *******************************************************
    .add('dashboard','/dashboard','dashboard/index')
    .add('profile_navigation','/dashboard/profile/navigation','dashboard/profile/navigation')
    .add('profile_userInfo','/dashboard/profile/user-information','dashboard/profile/userInfo')
    .add('profile_education','/dashboard/profile/education','dashboard/profile/education')
    .add('profile_sendCV','/dashboard/profile/send-cv','dashboard/profile/sendCV')
    .add('profile_skills','/dashboard/profile/skills','dashboard/profile/skills')
    .add('profile_honorAndResearch','/dashboard/profile/honor-and-research','dashboard/profile/honorAndResearch')
    .add('profile_language','/dashboard/profile/language-skill','dashboard/profile/language')
    .add('profile_workExperience','/dashboard/profile/work-experience','dashboard/profile/workExperience')
    .add('profile_profilePreview','/dashboard/profile/preview','dashboard/profile/profileView')
    .add('profile_favoriteJobs','/dashboard/profile/favorite-jobs','dashboard/profile/favoriteJobs')
    .add('profile_courses','/dashboard/profile/courses','dashboard/profile/courses')

当我这样使用链接时出现问题

import { Link } from '../../routes';
<Link route="dashboard">
   <a>Some text</a>
</Link>

我收到错误

Uncaught TypeError: Parameter 'url' must be a string,not undefined
at Url.push../node_modules/url/url.js.Url.parse (url.js:112)
at urlParse (url.js:106)
at Url.push../node_modules/url/url.js.Url.resolve (url.js:443)
at urlResolve (url.js:439)
at Link.getHref (link.js:8)
at Link.handleRef (link.js:8)
at ref (link.js:13)
lixb07072014 回答:将下一个js更新到v9后出现链接错误-参数“ url”必须为字符串,而不是未定义

当我将prefetch={false}添加到链接时,对我来说没关系。

<Link href="YOUR_LINK" prefetch={false} />

在此处查看更多说明:https://github.com/zeit/next.js/issues/8555

本文链接:https://www.f2er.com/2699284.html

大家都在问