2017-07-16 201 views
0

托管应用程序后成功后,督促建立与angualr4 + webpack3得到以下错误2日刷新浏览器的,IAM得到以下错误 uncaught exception: reflect-metadata shim is required when using class decorators Angular4 + webpack3督促建设得到错误的浏览器

,如果我下面更新的index.html脚本 <script src="Reflect.js"></script>

其工作正常 但为什么我需要把它放在index.html?是不是在webpack main.bundle.js中呈现?

回答

0

它看起来像你缺少一个polyfill。我在我的应用程序中使用了core-js的polyfills。

https://github.com/zloirock/core-js

安装此之后,有几种不同的方式得到它的工作。

如果使用polyfills切入点,添加:

import "core-js/es6/reflect" 
import "core-js/es7/reflect" 

如果你没有,你可以使用的WebPack ProvidePlugin一个polyfills切入点。添加到您的WebPack配置:

plugins: [ 
    ... 
    new webpack.ProvidePlugin({ 
    Reflect: 'core-js/es7/reflect' 
    }) 
    ... 
] 

where I got my answer