【发布时间】:2019-03-15 03:09:19
【问题描述】:
我正在开发一个 react 应用程序,如果用户的旧浏览器不支持 (例如 IE 9),客户希望它显示一条特殊消息。
这么久以来,我尝试使用react-device-detect 包检测一些“流行”的旧浏览器。
src/index.js
import { browserName, browserVersion } from "react-device-detect";
const render = Component => {
if (browserName === "IE" && browserVersion < 10) {
ReactDOM.render(<UnsupportedBrowser />, document.getElementById("root"));
} else {
ReactDOM.render(
<AppContainer>
<Component store={store} history={history} />
</AppContainer>,
document.getElementById("root")
);
}
};
并放置条件 cmets:
public/index.html
<!--[if lte IE 9]>
Please upgrade your browser
<![endif]-->
但我怀疑有更好的方法,但我在网上找不到。
【问题讨论】:
标签: reactjs google-chrome internet-explorer cross-browser