📜  向下滚动时反应引导隐藏切换菜单 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:27.833000             🧑  作者: Mango

代码示例1
import React, { Component } from 'react';

   class App extends Component {

   constructor(props) {
    super(props);

      this.state = {  scrollBackground: 'nav-bg' };
      this.handleScroll = this.handleScroll.bind(this);
   }


   handleScroll(){
      this.setState ({
         scrollBackground: !this.state.scrollBackground
       })
    }

 render() {
 const scrollBg = this.scrollBackground ? 'nav-bg scrolling' : 'nav-bg';

 return (
   
...
); } } export default App;