node.js - 将下一个 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)
解决方案
当我添加prefetch={false}
到 Link 时,这对我来说没问题。
<Link href="YOUR_LINK" prefetch={false} />
推荐阅读
- sql-server - Service Broker - 为输出 xml 文件制作触发器
- angular - Angular:使用文件中的配置数据预填充向导
- php - php获取字符串中的特定单词
- windows-services - 用于捕获服务挂起的 Procdump
- java - 无法使用 JRE 10 运行简单的 Java 应用程序
- angular - Angular 6 多次调用服务而不是一次
- .net-core - Service Fabric 本地群集使用哪个端口连接到外部服务(例如,Azure Blob 存储)?
- haskell - bind 可以由 fmap 和 join 组成,所以我们必须使用 monadic 函数 a -> mb 吗?
- python - 以类似“单元”的方式使用标准张量流层
- angular - 使用 as 关键字时,有没有办法在角度模板中保留类型?