iT邦幫忙

0

angular 6 has no exported member (已解決)

請問一下目前要在某個component import一個ts裡面的class進來,但一直顯示我沒export,看官方範例也是這樣放進來滿單純的,但錯誤一直顯示我沒有export class出來。

這是component,目前問題是Recipesdata抓不到

import { Component, OnInit } from '@angular/core';
import { Recipesdata } from '../recipes.component';


@Component({
  selector: 'app-recipes-list',
  templateUrl: './recipes-list.component.html',
  styleUrls: ['./recipes-list.component.scss']
})
export class RecipesListComponent implements OnInit {
  // recipes: Recipesdata[] = [
  //   new Recipesdata('a','b','v')
  // ]
  
  constructor() { }

  ngOnInit() {
  }

}

滑鼠放在Recipesdata上vscode會顯示:

[ts] 'Recipesdata' 已宣告但從未讀取其值。
[ts] 模組 '"省略我的路徑/src/app/recipes/recipes.component"' 沒有匯出的成員 'Recipesdata'。
import Recipesdata

這是要import的model../recipes.component路徑是沒有錯的,測過路徑

export class Recipesdata{
    public name:string;
    public description:string;
    public imagePath:string;
    constructor(name:string,desc:string,imagePath:string){
        this.name = name;
        this.description = desc;
        this.imagePath = imagePath;
    }
}

跑來來顯示錯誤:
ERROR in src/app/recipes/recipes-list/recipes-list.component.ts(2,10): error TS2305: Module '"省略我的路徑/src/app/recipes/recipes.component"' has no exported member 'Recipesdata'.

https://ithelp.ithome.com.tw/upload/images/20180709/20102709iICGXx79jH.png

Zaku iT邦新手 5 級 ‧ 2018-07-09 11:07:13 檢舉
找到問題了抱歉,引入錯誤,不是引入../recipes.component,而是要引入../recipes.model,../recipes.component剛好也存在,形成誤會,好像無法刪除發問
Homura iT邦新手 3 級 ‧ 2018-07-09 11:22:23 檢舉
標題後面加上(已解決)
Zaku iT邦新手 5 級 ‧ 2018-07-09 14:25:58 檢舉
改好了感謝

尚未有邦友回答

立即登入回答