NextJS URL params like React-Router

前端 未结 5 1206
一整个雨季
一整个雨季 2021-02-19 06:56

I\'m a newbie to NextJS, It looks so good on the first impression. But after giving it a chance I\'ve faced some problems like URL routing with custom params like react-router.<

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 07:42

    First import Router

    import Router from 'next/router'
    

    Then if you want to use it in a Link tag

    
    

    If you want to use it in a function or after a callback

    Router.push({
        pathname: '/about',
        query: { name: 'Sajad' },
      })
    

提交回复
热议问题