前端开发中必备的VSCode插件

915 阅读4分钟

持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第7天,点击查看活动详情

如果用好了VSCode插件,在日常开发中绝对是如虎添翼,大大提升开发效率。本文就推荐一些本人在Angular开发过程中常用的一些VSCode插件。

Angular Snippets (Version 13)

在日常开发工作中,经常需要频繁的创建Component,Directive,Service,Pipe,Ngrx片段,每次都徒手写一个,或者Copy一个,还是挺麻烦的,如果想要快速的写出一些代码片段,可以使用这个插件,非常的实用。

This extension for Visual Studio Code adds snippets for Angular for TypeScript and HTML.

提示的片段支持很多种,Angular片段,Ngrx片段,JS片段,HTML片段。

TypeScript Angular Snippets

SnippetPurpose
a-componentcomponent
a-component-inlinecomponent with inline template
a-component-rootroot app component
a-ctor-skip-selfangular NgModule's skipself constructor
a-directivedirective
a-guard-can-activateCanActivate guard
a-guard-can-activate-childCanActivateChild guard
a-guard-can-deactivateCanDeactivate guard
a-guard-can-loadCanLoad guard
a-httpclient-gethttpClient.get with Rx Observable
a-http-interceptorEmpty Angular HttpInterceptor for HttpClient
a-http-interceptor-headersAngular HttpInterceptor that sets headers for HttpClient
a-http-interceptor-loggingAngular HttpInterceptor that logs traffic for HttpClient
a-modulemodule
a-module-rootroot app module
a-output-event@Output event and emitter
a-pipepipe
a-preload-opt-in-strategycustom preload strategy that allows choosing which routes to preload
a-preload-network-strategycustom preload strategy that preloads based on network connectivity
a-resolverresolver
a-routesRoute definition file
a-rxjs-importimport RxJs features
a-rxjs-operatorsimport RxJs operators
a-route-path-404404 route path
a-route-path-defaultdefault route path
a-route-path-with-childrenroute path with children
a-route-path-eagereager route path
a-route-path-lazylazy route path
a-router-eventslisten to one or more router events
a-route-params-subscribesubscribe to route parameters
a-serviceservice with injectable provided in root
a-service-httpclientservice with HttpClient
a-subscribeRx Observable subscription
a-trackbyto create a trackby function in TypeScript for the ngFor

NgRx Snippets

SnippetPurpose
a-ngrx-store-modulecreate an NgRx store module
a-ngrx-create-actioncreate an NgRx action with createAction
a-ngrx-create-action-propscreate an NgRx action with createAction with props
a-ngrx-create-reducercreate an NgRx reducer with createReducer
a-ngrx-create-effectcreate an NgRx effect with createEffect
a-ngrx-create-effect-apicreate an NgRx effect with createEffect for an API call
a-ngrx-create-selectorcreate an NgRx selector with createSelector
a-ngrx-create-selector-propscreate an NgRx selector with createSelector with props
a-ngrx-data-entity-data-module-importadd EntityDataModule
a-ngrx-data-entity-metadatacreate the entity metadata for NgRx
a-ngrx-data-entity-collection-data-service

JavaScript Snippets

SnippetPurpose
ex-simple-serverNode.js Express Server

HTML Snippets

SnippetPurpose
a-class[class] binding
a-select control
a-style[style] binding
a-ngClassngClass
a-ngFor*ngFor
a-ngForAsync*ngFor with async
a-ngFor-trackBy*ngFor with trackBy
a-formcreate a form tag with ngSubmit and form attributes
a-formArrayNameformArrayName
a-formControlNameformControlName
a-formGroupformGroup
a-formGroupNameformGroupName
a-form-submitcreate a submit button for a form
a-ngIf*ngIf
a-ngIfElse*ngIf with else
a-ngModelngModel
a-routerLinkrouterLink
a-routerLink-paramrouterLink with a route parameter
a-ngStylengStyle
a-ngSwitchngSwitch
a-prejshow the JSON form of a model
a-prejashow the JSON form of a model, using async
a-ng-container element
a-ng-template element
a-ng-content element

功能逆天了,太方便了。

Angular Language Service

在Angular中,如果你想在HTML模板中引用内部或者外部变量时,VSCode不会有提示功能。但是,作为开发者,你希望在模板中对引用的内部或外部变量时,有所提示,提高开发体验,那就可以使用Angular Language Service这个插件。

This extension provides a rich editing experience for Angular templates, both inline and external:

  • Completions lists
  • Go to definition
  • AOT Diagnostic messages
  • Quick info

这个插件基于内部或外部的变量,对Angular的模板提供丰富的编辑体验。对于模板中引用的变量有智能提示,还可以转到定义,这个功能实在是太有用了。

Code Spell Checker

这个插件是对代码中单词拼写错误的进行提示,妈妈在也不用担心我写错单词了。尽管大部分情况下,我们拼写英文单词出现了错误,虽然不影响阅读,但是显得不专业哦。

A basic spell checker that works well with camelCase code.

Code Runner

日常写一段JS代码做个测试什么的,用VSCode自带的运行工具有点麻烦,有没有一键运行的啊?当然是有了。

一键运行多种语言运行代码片段或代码文件: C,C+ + ,Java,JavaScript,PHP,Python,Perl,Perl 6,Ruby,Go,Lua,Groovy,PowerShell,BAT/CMD,BASH/SH,f # Script,f # (.NET 核心) ,C# 脚本,多到你想不到。

支持快捷键哦,Ctrl + Alt + N运行,Ctrl + Alt + M停止运行。

Live Server

平时写个html页面,怎么使用HTTP协议访问页面呢?不要使用文件协议访问,有些情况可能不是预期的。

SVG Viewer

项目中很多SVG文件,可是无法预览,想找一个想要的ICON,真是费尽啊,只能拖入浏览器进行查看。有了SVG Viewer就可以直接在VSCode里查看了,还能导出图片,爱了爱了。

Git Lens

可以查看代码的Git历史。

CSS Peek

模板中引用的class定义在哪里,找起来好麻烦啊,快使用CSS Peek。

好了,看看你喜欢那个插件,赶快用起来吧,有了这些工作小助手,工作效率大大地提高。