【问题标题】:Not able to import class in angular 5无法在角度 5 中导入类
【发布时间】:2018-12-20 10:11:11
【问题描述】:

我正在尝试以 Angular 5 导入我的类。但它显示错误,例如“已声明类但从未读取其值”。你能帮我如何在没有错误的情况下导入课程吗?我需要在movies.component.ts 文件中导入Movie 类

 movie.ts 

     export class Movie {
       id : number;
       name : string;
     }


 movies.component.ts

      import { Component, OnInit } from '@angular/core';

      import { Movie } from "../../models/movie";   //error in this line

       @Component({
         selector: 'app-movies',
         templateUrl: './movies.component.html',
         styleUrls: ['./movies.component.css']
      })
      export class MoviesComponent implements OnInit {

       constructor() { }

        ngOnInit() {
    }

    }

【问题讨论】:

    标签: typescript import angular5


    【解决方案1】:

    这不是错误,只是警告。您已导入 Movie 类,但尚未在 MoviesComponent 的任何地方使用它。

    【讨论】:

      【解决方案2】:

      你需要使用你的电影类,我会说这个错误是预期的。

      【讨论】:

        猜你喜欢
        • 2023-02-08
        • 1970-01-01
        • 1970-01-01
        • 2018-07-26
        • 1970-01-01
        • 2018-08-13
        • 1970-01-01
        • 2016-12-19
        • 2020-11-17
        相关资源
        最近更新 更多