填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

NG0301: Export not found!
沒有找到此匯出!

說明

Description

Angular 找不到帶有 {{ PLACEHOLDER }} 匯出名稱的指令。匯出名稱在指令裝飾器的 exportAs 屬性中指定。在範本中使用 FormsModule 或 Material 模組時,這很常見,因為你忘記了匯入相應的模組

Angular can’t find a directive with {{ PLACEHOLDER }} export name. The export name is specified in the exportAs property of the directive decorator. This is common when using FormsModule or Material modules in templates, and you’ve forgotten to import the corresponding modules.

這是常見的編譯器錯誤 NG8003:找不到帶有 export 的指令的執行期等價物。

This is the runtime equivalent of a common compiler error NG8003: No directive found with export.


如何排除本錯誤

Debugging the error

根據此匯出名來追蹤使用了此匯出的範本或模組。

Use the export name to trace the templates or modules using this export.

確保所有依賴項都已正確匯入並在 NgModules 中宣告。例如,如果未找到名為 ngForm 的匯出,則需要匯入 FormsModule,並把它新增到 *.module.ts 中的匯入(imports)列表中來宣告它,以解決該錯誤。

Ensure that all dependencies are properly imported and declared in your NgModules. For example, if the export not found is ngForm, we need to import FormsModule and declare it in the list of imports in *.module.ts to resolve the error.

      
      import { FormsModule } from '@angular/forms';

@NgModule({
  ...
  imports: [
    FormsModule,
    
    

如果你最近添加了匯入,則可能需要重新啟動伺服器以檢視這些更改。

If you recently added an import, you may need to restart your server to see these changes.