chunk {main} main.js,main.js.map(主)2.1 kB [初始] [呈现]无法读取角度未定义的属性“ map”

问题描述 投票:-2回答:1

enter image description here

以上是我得到的错误。我无法解决它,因为我没有得到它正在发生的文件。

以下是我的component.ts文件:

<div class="loginBody">
    <div class="login-page">
        <img src="./assets/logo.png" id="logo">
        <form [formGroup]="signin">

            <mat-form-field id="email">

                <input matInput placeholder="@meltwater.com" formControlName="emailFormControl">
                <mat-hint>Enter your email</mat-hint>
                <mat-error *ngIf="emailInput.hasError('email') && !emailInput.hasError('required')">
                    Please enter a valid email address
                </mat-error>

            </mat-form-field>
            <br>
            <mat-form-field id="password">
                <input matInput placeholder="password" [type]="hide ? 'password' : 'text'" formControlName="passwordFormControl" required>
                <mat-icon matSuffix (click)="hide = !hide">{{hide ? 'visibility_off' : 'visibility'}}</mat-icon>
                <mat-hint *ngIf="!passwordInput.value">Enter your password</mat-hint>
            </mat-form-field>
            <br>
            <mat-checkbox>Remember me</mat-checkbox>
            <br>
            <button id="loginButton" mat-raised-button routerLink='/login' routerLinkActive='active'>LOG IN</button>
            <br>
            <p class="message">Using company credentials? <a href="#"> Log in with SSO</a></p>
            <a href="#">Forgot password?</a>

        </form>

    </div>

</div>

这是插入图片的错误。我尚未在任何文件中添加任何地图元素。

以下是我的app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';


const routes: Routes = [];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

这是我的index.html

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>AppliedInsightFrontend</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>

<body>
    <app-root></app-root>
</body>

</html>

这将是我的main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));

以下为完整错误:

0% compiling
Compiling @angular/core : es2015 as esm2015
10% building 3/3 modules 0 activeℹ 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: 404s will fallback to //index.html

chunk {main} main.js, main.js.map (main) 2.1 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 127 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 177 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 340 kB [initial] [rendered]
Date: 2020-03-25T14:38:50.300Z - Hash: 5926a3d885deed4ad147 - Time: 3212ms

ERROR in Cannot read property 'map' of undefined
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Failed to compile.
angular typescript mean-stack
1个回答
0
投票

很多时候,从属组件不会导入所需的所有内容。

从此开始:ng update @ angular / material

如果不起作用...删除项目中的npm缓存(或文件夹本身),然后从package.json的文件夹位置键入npm install。

如果不起作用,则可以尝试将ng更新到(8或9)的最新版本。

如果不起作用,您可以尝试npm更新@ angular / material @ ^ X.Y.Y

© www.soinside.com 2019 - 2024. All rights reserved.