简体   繁体   English

Typescript导入导入angular2路由器错误

[英]Typescript import import angular2 router errors

I am using the following import statement in my TypeScript code 我在我的TypeScript代码中使用以下import语句

import { Routes, RouterModule } from "@angular/router";

I have a few questions about this 我有几个问题

  1. What does the "@" symbol mean in "@angular/router" "@angular/router" “@”符号的含义是什么
  2. I am using angular2 when I try to compile I get the following error cannot find module @angular/router . 我在尝试编译时使用angular2我得到以下错误cannot find module @angular/router I am using "angular2": "2.0.0-beta.7", 我使用的是"angular2": "2.0.0-beta.7",

What does the "@" symbol mean in "@angular/router" “@ angular / router”中“@”符号的含义是什么

The '@' is just the name of the library. '@'只是库的名称。 If you look at the systemjs.config at the bottom of the 5 Min Quickstart on angular.io-s web site that's how it's mapped. 如果你看一下angular.io-s网站上5 Min Quickstart底部的systemjs.config,它是如何映射的。

Also if you look in to the package.json file. 另外,如果你查看package.json文件。 '@angular/...' is the literal name of the package. '@angular / ...'是包的文字名称。

I am using angular2 when I try to compile I get the following error cannot find module @angular/router. 我在尝试编译时使用angular2我得到以下错误找不到模块@ angular / router。 I am using "angular2": "2.0.0-beta.7" 我使用的是“angular2”:“2.0.0-beta.7”

Firstly you should really consider updating to the new version 'RC5' there were a bunch of breaking changes and fixes. 首先你应该考虑更新到新版本'RC5',有一些重大变化和修复。

The reason why you get the error cannot find module @angular/router is probably because you have it mapped wrongly in your systemjs config or you're trying to install a version of the 'router' that doesn't exist. 你得到错误的原因是cannot find module @angular/router可能是因为你在systemjs配置中错误地映射了它,或者你正在尝试安装一个不存在的'router'版本。

I think you should really try to follow the 5 Min Quickstarter to set up the initial project and then follow the Routing and Navigation documentation for the routing part. 我认为您应该尝试按照5 Min Quickstarter设置初始项目,然后按照路由部分的路由和导航文档进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM