路径匹配的angular2路由问题 [英] angular2 Routing issue with pathmatch

查看:77
本文介绍了路径匹配的angular2路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我决定重试angular2教程,因为上次我在路由器方面遇到了一些问题(听起来很熟悉吗?).见链接: Angular 2教程 在执行每个步骤的地方,一切正常,直到进入重定向部分.

So I decided to retry the angular2 tutorial, since last time I had some issues with the router (sound familiar?). See link: Angular 2 tutorial Where I followed every step, got everything to work, until I got to the redirect section.

{
  path: '',
  redirectTo: '/dashboard',
  pathMatch: 'full'
},

它挂在"pathMatch"上的位置.即使当我尝试在命令窗口中使用"npm start"重新启动时,也会出现此错误:

Where it hangs on the "pathMatch". Even when I try to restart with "npm start" in the command window, I get this error:

app/app.routes.ts(11,5): error TS2322: Type '({ path: string; redirectTo: string; pathMatch: string; } | { path: string; component: typeof Das...' is not assignable to type 'Route[]'.

在package.json中定义的我的路由器版本是: "@ angular/router":"3.0.0-alpha.7",我以为是最新版本?

My router version defined in package.json is: "@angular/router": "3.0.0-alpha.7", of which i thought was the latest version?

如何检查项目/电脑上实际安装了哪个routerversion?我对整个npm-deal都是陌生的,试图解决这个问题我感到很困惑.我猜我可能有旧的路由器版本?

How can I check which routerversion is actually installed on my project/pc? I'm kind of new to the whole npm-deal and I'm getting stumped trying to figure this thing out. I'm guessing I may have an old router version?

预先感谢您的帮助.

推荐答案

好吧,我想您现在应该已经找到答案了,但是这里是您如何检查系统上安装了哪个版本的路由器的

Okay I guess you should have found the answer by now, but here is how you can check which version of router is installed on your system

进入node_modules文件夹,然后进入@angular,然后进入路由器

Go into node_modules folder and then into @angular, and into router

node_modules/@ angular/router
├──README.md
├──包
├──index.d.ts
├──index.js
├──index.js.map
├──index.metadata.js enter code here
上 ├──package.json< -----------此文件应告诉您版本
├──src

node_modules/@angular/router
├── README.md
├── bundles
├── index.d.ts
├── index.js
├── index.js.map
├── index.metadata.jsenter code hereon
├── package.json <----------- This file should tell you the Version
├── src

希望您的问题得到解决. 谢谢.

I hope your problem was solved. Thanks.

这篇关于路径匹配的angular2路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆