查找Angular2类源代码 [英] Finding Angular2 class source code

查看:56
本文介绍了查找Angular2类源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Angular2,并且在查找导入类的位置时遇到问题.

I'm in the process of learning Angular2 and am having issues finding where imported classes are located.

例如,在我的代码中,我将从'angular2/core'导入{Component};

For example, in my code I would have import {Component} from 'angular2/core';

现在,当我转到 core.d.ts 文件时,有一堆 * 导出文件,而没有明显的 Component 导出的类.我知道,如果我浏览所有这些文件,某处将有一个 export class Component .显然,这并不理想,但是我想我缺少了一种更简单的方法来找到 Component 类的源代码.

Now, when I go to the core.d.ts file, there are a bunch of * exports and nowhere is there explicitly a Component class exported. I know that if i go through all those files, somewhere there will be an export class Component. Obviously that is not ideal, but I'm guessing I'm missing some easier way to find the source code for the Component class.

推荐答案

如果使用的是诸如VS Code之类的工具,则可以在import语句中右键单击 Component 词,然后选择转到定义" .这将直接带您到源代码.

If you are using a tool such as VS Code, you can right-click on the Component word within the import statement and select Go to Definition. That takes you directly to the source code.

请注意,从Angular 2 RC 1开始,您所拥有的导入不再正确.导入现在为@ angular/core.

And note that the import you have is no longer correct as of Angular 2 RC 1. The import is now @angular/core.

这篇关于查找Angular2类源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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