首页 > 解决方案 > 类型“ArtistDetailsComponent”上不存在属性“艺术家”。类型“ArtistDetailsComponent”

问题描述

我无法构建我的应用程序。当我使用“ng serve”时,一切正常,但“ng build”失败并出现错误:

类型“ArtistDetailsComponent”上不存在属性“艺术家”。

<div class="container mt-3">
  <div class="row justify-content-center">
    <div class="col-sm-4 col-lg-3">
      <img class="img-fluid rounded" src="'./assets/images/' + artist.shortname + '.jpg'" alt="{{artist.name}} photo">
    </div>
    <div class="col-sm-8 col-lg-4">
      <h2 class="mt-3 mt-sm-0 mb-0">{{artist.name}}</h2>
      <h4 class="mt-0">{{artist.reknown}}</h4>
      <p>{{artist.bio}}</p>
    </div>
  </div>
</div>
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-artist-details',
  templateUrl: './artist-details.component.html',
  inputs: ['artist']
})
export class ArtistDetailsComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

我该如何解决?更多代码在这里:代码

标签: angular

解决方案


import { Component, OnInit, Input } from '@angular/core';
@Component({
  selector: 'app-artist-details',
  templateUrl: './artist-details.component.html'
})
export class ArtistDetailsComponent implements OnInit {

  // If the Artiste type exists and don't forget to import it
  @Input() artiste: Artiste;

  constructor() { }

  ngOnInit() {}
}

推荐阅读