我使用fetch-mock来模拟使用fetch的实际组件。fetch-模拟不支持ie11,并且只在浏览器被支持的情况下才想导入示例组件。我怎样才能做到这一点?
fetch-mock来模拟ABCComponent中使用的fetch。LoadComponent
const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
if(!isIE11){
import ABCExampleComponent from './ABCExampleComponent';
}
//or
const ABCExampleComponent = !isIE11 ? import('./ABCExampleComponent') : null;
const LoadComponent = ( ) => {
<ABCExampleComponent />
}谢谢你的建议。
发布于 2018-11-07 22:08:28
我不知道我是否完全理解你的问题,但是试试这个const Abc = condition ? require('ComponentA') : require('componentB')
https://stackoverflow.com/questions/53196203
复制相似问题