zoukankan      html  css  js  c++  java
  • [React Intl] Use Webpack to Conditionally Include an Intl Polyfill for Older Browsers

    Some browsers, such as Safari < 10 & IE < 11, do not support the JavaScript Internationalization API, which react-intl depends on. In order to support these browsers, we’ll conditionally include an Intl polyfill using webpack require.ensure. This ensures only browsers that need the polyfill incur the extra load.

    if (!window.Intl) {
      require.ensure([
        'intl',
        'intl/locale-data/jsonp/en.js',
        'intl/locale-data/jsonp/fr.js',
        'intl/locale-data/jsonp/es.js'
      ], (require) => {
        require('intl');
        require('intl/locale-data/jsonp/en.js');
        require('intl/locale-data/jsonp/fr.js');
        require('intl/locale-data/jsonp/es.js');
    
        runApp();
      })
    } else {
      runApp();
    }
    
    function runApp() {
      addLocaleData([...en, ...fr, ...es]);
    
      let locale = (navigator.languages && navigator.languages[0])
        || navigator.language
        || navigator.userLanguage
        || 'en-US';
    
      ReactDOM.render(
        <IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
          <App />
        </IntlProvider>,
        document.getElementById('root')
      );
    }
  • 相关阅读:
    hadoop yarn日志分离
    hadoop优化
    hive UDF
    hadoophttpfs
    spark编译
    spark feature
    python
    python 装饰器
    HTML特殊转义字符列表
    博客园数据统计
  • 原文地址:https://www.cnblogs.com/Answer1215/p/7265872.html
Copyright © 2011-2022 走看看