Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

javascript - Next/router nothing happens when browser’s back button click

I don't understand why, when I click on browser’s back button my page doesn't reload.

I have a catalog component inside /pages/index.js which is my home page, a dynamic route to navigate to the products /pages/books/[name].js

This is the Link I use to go to the products pages :

<div className="container-cat">
       {products.map((_product) => (
                    <Card id="lien" key={_product.id} alt="book" className="catalogue">
                    <Link href='/books/[name]' as={`/books/${_product.name}`}>
                      <a>
                      <Card.Body>
                      <Card.Img variant="top" src={getStrapiMedia(_product.grid_pic.url)} width="200px" />
                        <Card.Title>{_product.name}<br />{_product.author}<br />{_product.price} €</Card.Title>
                      </Card.Body>
                      </a>
                      </Link>
                    </Card>
               
            ))
          }

      </div>

I don't know what else to put here ...

question from:https://stackoverflow.com/questions/65900917/next-router-nothing-happens-when-browser-s-back-button-click

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I change my routes, putting the catalog component as the index.js of the /pages/books/

I can't really explain why, but it works


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...