我正在尝试将materialize.css Paralex插件集成到我的react hook功能组件中。我怎么做 ?这是代码
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.parallax');
var instances = M.Parallax.init(elems, options);
});
请协助
答案 0 :(得分:0)
这是处理类组件的方法:
componentDidMount() {
var elems = document.querySelectorAll('.parallax');
var instances = M.Parallax.init(elems, options);
}
功能组件:
useEffect(() => {
var elems = document.querySelectorAll('.parallax');
var instances = M.Parallax.init(elems, options);
}, [])
希望这就是您所需要的:)