2017-07-16 200 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