我fetch-mock
用来模拟使用 fetch 的实际组件。fetch-mock 不支持 ie11 并且希望仅在支持浏览器的情况下导入示例组件。我怎样才能做到这一点?
- ABCExampleComponent
fetch-mock
用于ABCComponent 中使用fetch
的模拟。 - 仅当浏览器受支持时,LoadComponent 才应呈现 ABCExampleComponent。
加载组件
const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
if(!isIE11){
import ABCExampleComponent from './ABCExampleComponent';
}
//or
const ABCExampleComponent = !isIE11 ? import('./ABCExampleComponent') : null;
const LoadComponent = ( ) => {
<ABCExampleComponent />
}
感谢您的建议。