2017-06-01 166 views
0

我在我的React應用中使用Firebase和FirebaseUI進行電話號碼註冊。正如你可以在http://brigadesaffinitywebapp-dev.herokuapp.com看到的那樣,它在谷歌Chrome桌面上運行良好,但只要我嘗試使用另一個導航器,國家代碼選擇器不起作用並拋出錯誤:undefined is not an object (evaluating 'window.dialogPolyfill.registerDialog')。所以我想我需要整合https://github.com/GoogleChrome/dialog-polyfill,但我很難弄清楚如何。如何將dialog-polyfill集成到我的React應用程序中?

我試圖npm install dialog-polyfill然後import dialogPolyfill from 'dialog-polyfill但我仍然得到錯誤。也許這與我目前沒有將實例附加到window對象的事實有關?

回答

0

我想沒有理由使事情變得複雜...只是不得不把這個index.html的頂部

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.7/dialog-polyfill.js"></script> 

<script> 
    var dialog = document.querySelector('dialog'); 
    dialogPolyfill.registerDialog(dialog); 
    // Now dialog acts like a native <dialog>. 
    dialog.showModal(); 
</script> 
+0

只是想指出,這是一個FirebaseUI不受歡迎的行爲所在的包應該包括並加載dialog-polyfill,但它並不明顯:https://github.com/firebase/firebaseui-web/issues/150 –

相關問題