2017-02-20 71 views
0
的所有參數

我構建了一個SPFx角度2組件,該組件具有嵌套的子組件。子組件需要引用當前上下文,但如果我這樣做:未處理的Promise拒絕:無法解析

import { 
    IWebPartContext 
} from '@microsoft/sp-webpart-base'; 

constructor(context: IWebPartContext) { 

我得到:

Unhandled Promise rejection: Can't resolve all parameters for ...

或者,如果我這樣做:

constructor(@Inject(context) context: IWebPartContext) { 

我收到:

SPComponentLoader.loadComponent: ERROR: ***Failed to load entry point from component "ffaa6a0e-9eba-40a0-bec5-226d1db53caf" (RequirementsFormWebPart). DefaultLogHandler.error @ DefaultLogHandler.js:15 Log.error @ Log.js:19 (anonymous) @ SPSystemJsComponentLoader.js:225 TraceLogger.js:69 [1487550303166][Shell.ClientSideWebPartManager] [SPWebPartErrorCode.ScriptLoadError]:: Unable to load web part WebPart.RequirementsFormWebPart.7a18b99b-78ca-4d0e-b087-189bbe751b7d,Error: ***Failed to component "ffaa6a0e-9eba-40a0-bec5-226d1db53caf" (RequirementsFormWebPart). Original error: Error loading https://component-id.invalid/ffaa6a0e-9eba-40a0-bec5-226d1db53caf_0.0.1 script resources due to: undefined. CALLSTACK:: Error

任何想法?

問候,

回答

0

通過注射不解決,而是隻需要實例化。

 public context: IWebPartContext; 

     constructor() { 
     this.model = new TaxonomyModel(this.context); 
     } 
相關問題