我在我的 ReactJS 项目中使用 malihu-custom-scrollbar-plugin,我可以通过编辑 node_modules 中的 css 来自定义滚动条,在 npm install 之后出现的问题 node_modules 中的所有更改都将消失,我需要一种方法来编辑滚动条拖动器和滚动条轨道的大小、颜色。还有向上和向下按钮,在 src 文件中而不是在节点模块中
这是我用于 malihu-custom-scrollbar-plugin 的代码:
import Box from '@mui/material/Box'
import $ from 'jquery';
import 'malihu-custom-scrollbar-plugin';
import 'malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css';
require('jquery-mousewheel');
const ListComponent = () => {
React.useEffect(()=>{
$('.scroll').mCustomScrollbar({
scrollButtons:{enable:true},
theme:"rounded-dots-dark",
scrollInertia:500
});
},[])
return (
<Box style={{overflowY: "hidden",
height: "300px"}} className='scroll'>
<p> A long lines of text</p>
</Box>
)
}