我最近将 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)