我使用ng build --prod
命令完成了项目构建。它生成成功构建,但此构建无法在实时服务器上运行,它给出以下错误:-
main.0769518151819531d924.js:1 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'hasOwnProperty' of undefined
TypeError: Cannot read property 'hasOwnProperty' of undefined
at v (main.0769518151819531d924.js:1)
at Mf (main.0769518151819531d924.js:1)
at t.get (main.0769518151819531d924.js:1)
at kt (main.0769518151819531d924.js:1)
at Pt (main.0769518151819531d924.js:1)
at Et (main.0769518151819531d924.js:1)
at main.0769518151819531d924.js:1
at main.0769518151819531d924.js:1
at Df (main.0769518151819531d924.js:1)
at Mf (main.0769518151819531d924.js:1)
at P (polyfills.7d30aceca8fe7a5b6974.js:1)
at P (polyfills.7d30aceca8fe7a5b6974.js:1)
at polyfills.7d30aceca8fe7a5b6974.js:1
at e.invokeTask (polyfills.7d30aceca8fe7a5b6974.js:1)
at Object.onInvokeTask (main.0769518151819531d924.js:1)
at e.invokeTask (polyfills.7d30aceca8fe7a5b6974.js:1)
at t.runTask (polyfills.7d30aceca8fe7a5b6974.js:1)
at g (polyfills.7d30aceca8fe7a5b6974.js:1)
at t.invokeTask [as invoke] (polyfills.7d30aceca8fe7a5b6974.js:1)
at m (polyfills.7d30aceca8fe7a5b6974.js:1)
1条答案
按热度按时间3lxsmp7m1#
我不确定这里使用的代码行或对象类型是什么,但是,通常如果您收到此错误-那么您可能需要在使用它们之前检查变量。
在Angular 7中,你可能会使用TypeScript(?),这样的话,您使用的是类似
export class ..
的东西,在这种情况下,hasOwnProperty
不存在(在interface / type
上,您确实存在。在typescript中,你有各种各样的选项来在使用它之前首先检查你是否有一个值。例如:
等等等等