小编Dan*_*rop的帖子

移动导航菜单打开时防止滚动?

我有一个从汉堡打开的简单导航菜单。当它打开时,如何防止屏幕上的所有滚动?导航栏是 100vh,我想防止在它打开时滚动经过它?

到目前为止导航菜单的 Js(没有滚动功能)

const navSlide = () => {
    const burger = document.getElementById('burger')
    const nav = document.getElementById('nav')
    const navLinks = document.querySelectorAll('.nav-links li')
    
    burger.addEventListener('click', () => {
        nav.classList.toggle('nav-active')
        navLinks.forEach( (link, index) => {
            if (link.style.animation) {
                link.style.animation = ''
            } else {
                link.style.animation = `navLinkFade 0.7s ease forwards ${index / 7 + 0.4}s`
                }
    })
    burger.classList.toggle('toggle')
  })
}

navSlide()
Run Code Online (Sandbox Code Playgroud)

javascript nav responsive

5
推荐指数
1
解决办法
6333
查看次数

Cannot destructure property 'data' of '(intermediate value)' as it is undefined

This error is in the console and it prevents the app from working, I cant find the bug at all if anyone could help? Its a MERN application

The code in question

export const getPosts = () => async (dispatch) => {
    try {
      const { data } = await api.fetchPosts();
  
      dispatch({ type: 'FETCH_ALL', payload: data });
    } catch (error) {
      console.log(error.message);
    }
  };
Run Code Online (Sandbox Code Playgroud)

VSC is telling me await doesn't effect this kind of expression, which it should as fetchPosts …

javascript reactjs

3
推荐指数
1
解决办法
4099
查看次数

标签 统计

javascript ×2

nav ×1

reactjs ×1

responsive ×1