简体   繁体   English

我怎样才能将对话框和polyfill集成到我的React应用程序中?

[英]How can I Integrate dialog-polyfill into my React app?

I'm using Firebase and FirebaseUI in my React app for phone number registration. 我在我的React应用程序中使用Firebase和FirebaseUI进行电话号码注册。 As you can see at http://brigadesaffinitywebapp-dev.herokuapp.com it works well on Google Chrome desktop but as soon as I try to use another navigator the country code selector doesn't work and throws an error : undefined is not an object (evaluating 'window.dialogPolyfill.registerDialog') . 如您在http://brigadesaffinitywebapp-dev.herokuapp.com上看到的那样,它在Google Chrome桌面上运行良好,但是当我尝试使用其他导航器时,国家/地区代码选择器不起作用并抛出错误: undefined is not an object (evaluating 'window.dialogPolyfill.registerDialog') So I guess I need to integrate https://github.com/GoogleChrome/dialog-polyfill but I'm having a hard time figuring out how. 所以我想我需要集成https://github.com/GoogleChrome/dialog-polyfill,但是我很难弄清楚该如何做。

I tried to npm install dialog-polyfill and then import dialogPolyfill from 'dialog-polyfill but I still get the error. 我试图npm install dialog-polyfill import dialogPolyfill from 'dialog-polyfill ,然后import dialogPolyfill from 'dialog-polyfill但仍然出现错误。 Maybe it has something to do with the fact that I'm not currently attaching the instance to the window object ? 可能与我当前未将实例附加到window对象的事实有关?

I guess there is no reasons to complicate things... Just had to put this a the top of index.html 我想没有任何理由使事情复杂化……只需将其放在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM