我用的是vuejs和nuxt。
当使用 mysite.com/page1#section1 时,我想转到 page1 并关注 section1。
在我的代码中我有:
<div id="section1">...</div>
但这不适用于新页面。当我在 mysite.com/page1 页面上并将 #section1 添加到 url 时,它起作用了。
那么,如何在打开新页面时使 anchor 起作用?我应该在路由器中添加一些东西吗?
最佳答案
你应该使用这样的链接:
<a href="http://youpage.com/child#section1">go to section 1 in child page</a>
在 child 使用中:
<div id="section1"></div>
关于 anchor 链接的 W3C 规范:https://www.w3.org/TR/REC-html40/struct/links.html#h-12.2.3
关于javascript - 在特定的 div 上打开一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58059246/