reactjs - 未指定任何元素来初始化 Windows 上的 PerfectScrollbar
问题描述
我在 react js 的服务器启动时收到此错误。
错误:没有指定元素来初始化 PerfectScrollbar
但是它在 Ubuntu 操作系统上运行良好。我正在使用窗户。
提前致谢
这是相关代码
// creates a beautiful scrollbar
import PerfectScrollbar from "perfect-scrollbar";
import "perfect-scrollbar/css/perfect-scrollbar.css";
// ref to help us initialize PerfectScrollbar on windows devices
const mainPanel = React.createRef();
const useStyles = makeStyles(styles);
// initialize and destroy the PerfectScrollbar plugin
React.useEffect(() => {
if (navigator.platform.indexOf("Win") > -1) {
ps = new PerfectScrollbar(mainPanel.current, {
suppressScrollX: true,
suppressScrollY: false,
});
document.body.style.overflow = "hidden";
}
window.addEventListener("resize", resizeFunction);
// Specify how to clean up after this effect:
return function cleanup() {
if (navigator.platform.indexOf("Win") > -1) {
ps.destroy();
}
window.removeEventListener("resize", resizeFunction);
};
}, [mainPanel]);
解决方案
推荐阅读
- groovy - 使用映射遍历 groovy 中的 JSON 对象
- java - 如何使用hibernate createQuery或criteriaQuery连接两个表如何使用注释映射
- java - Spring Security 的 permitAll 未授权
- ios - 使用 VB.NET 读取 iOS 驱动器
- javascript - concatMap 无法处理数组中的所有项目
- hive - Hive SQL - 拆分字符串固定长度
- php - PHP - 服务器端 HTML
- c++ - Accidentally dragged a file
- python - Pandas Concatenation no longer has sort keyword argument
- branch.io - 分支 io 添加自定义数据