天天看點

如何處理UI5一般性錯誤Cannot read property md of undefined

Suppose you have encountered with this error when you launch your Fiori application:

Uncaught Error: failed to load ‘FioriTest/view/Master.controller.js’ from ./view/Master.controller.js: TypeError: Cannot read property ‘md’ of undefined

The error is raised in framework file UIComponent-dbg.js. In most of the case the error is not in framework side, but due to wrong code in your own application code.

如何處理UI5一般性錯誤Cannot read property md of undefined

1). click the hyperlink:

如何處理UI5一般性錯誤Cannot read property md of undefined

2). You will be automatically navigated to the code where the exception - the error message is raised.

Set a breakpoint here:

如何處理UI5一般性錯誤Cannot read property md of undefined

3). re-launch your Fiori application, the breakpoint is triggered, you can then find the detail callstack by evaluating the variable e:

如何處理UI5一般性錯誤Cannot read property md of undefined
如何處理UI5一般性錯誤Cannot read property md of undefined

Search in Opportunity application, and we realized that there is a missing require statement:

如何處理UI5一般性錯誤Cannot read property md of undefined

after the require statement above is added, the error message changes:

如何處理UI5一般性錯誤Cannot read property md of undefined
如何處理UI5一般性錯誤Cannot read property md of undefined

so we are still lack of another necessary require statement, and this is the root cause of the error message. Once we add the missing require statement, issue will be resolved.

如何處理UI5一般性錯誤Cannot read property md of undefined

繼續閱讀