小编Dan*_*llo的帖子

不再需要 core-js 了吗?

我已经将一个 Angular 项目从版本 7 更新到了 8。一切运行顺利,原理图完成了它的工作(也许),我们还好(项目甚至在生产中)。当我们更新 Angular CLI 时,我们总是会生成一个新项目来查看真正的差异并从中学习,例如新的依赖项、配置等。

使用 Angular CLI 8.0.4 生成新的 Angular 项目时,新应用程序没有core-js依赖项:

"dependencies": {
    "@angular/animations": "~8.0.1",
    "@angular/common": "~8.0.1",
    "@angular/compiler": "~8.0.1",
    "@angular/core": "~8.0.1",
    "@angular/forms": "~8.0.1",
    "@angular/platform-browser": "~8.0.1",
    "@angular/platform-browser-dynamic": "~8.0.1",
    "@angular/router": "~8.0.1",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  }
Run Code Online (Sandbox Code Playgroud)

core-js不存在对构建项目的分析包: 没有 core-js 的捆绑包 在我使用 Angular CLI 更新的项目中,core-js是否存在并且存在于最终包中:

"dependencies": {
    "@angular/animations": "~8.0.3",
    "@angular/cdk": "~8.0.1",
    "@angular/common": "~8.0.3",
    "@angular/compiler": "~8.0.3",
    "@angular/core": "~8.0.3",
    "@angular/forms": "~8.0.3",
    "@angular/platform-browser": "~8.0.3",
    "@angular/platform-browser-dynamic": "~8.0.3",
    "@angular/router": "~8.0.3",
    "@auth0/angular-jwt": "2.1.1",
    "@hackages/ngxerrors": "~8.0.0",
    "@ng-bootstrap/ng-bootstrap": "5.0.0-rc.1",
    "@ngx-loading-bar/core": …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular angular8

33
推荐指数
2
解决办法
2万
查看次数

如何在静态方法中使用class作为参数

我在处理XML文档的类中有一个静态方法(相关)(不那么相关).该方法看起来像这样......

public static bool ProcessFormFile(IFormFile formFile, ModelStateDictionary modelState, string fileExtensionToValidate = "docx")
{
    //...some logic & stuff
    MemberInfo property = typeof(UploadTemplateViewModel).GetProperty(formFile.Name.Substring(formFile.Name.IndexOf(".") + 1));

    //... all the rest
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我正在使用反射来获取一些属性UploadTemplateViewModel.问题是我需要使用另一个类来动态这个类,SomeOtherViewModel并在方法中使用它.

我试过用这样的东西......

public static bool ProcessFormFile(IFormFile formFile, ModelStateDictionary modelState, T entity, string fileExtensionToValidate = "docx") where T : class
Run Code Online (Sandbox Code Playgroud)

......但是我知道了Constraints are not allowed on non-generic declarations.这是我一直想要了解更多信息的topice,但这是我第一次在真实情况下使用它.

我怎样才能实现这一目标?将方法从静态更改为公共或类似的东西?提前致谢.

该方法有效,我可以通过反射得到属性,我只需要使用 typeof(somethingInMethodParameters).GetProperty()

c#

-1
推荐指数
1
解决办法
48
查看次数

标签 统计

angular ×1

angular-cli ×1

angular8 ×1

c# ×1