Nuxt.js 和锚点 [英] Nuxt.js and anchors

查看:254
本文介绍了Nuxt.js 和锚点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理 Nuxt.js 中的锚点(在同一页面内)?

How to deal with anchors (within the same page) in Nuxt.js ?

问题是 URL 始终位于基础 localhost:3000/我也想在 URL 上显示锚点:localhost:3000/#anchor1, localhost:3000/#anchor2, localhost:3000/#anchor3代码> ...等

Problem is the URL stays always on the base localhost:3000/ I want to have anchors displayed on the URL too: localhost:3000/#anchor1, localhost:3000/#anchor2, localhost:3000/#anchor3 … etc.

似乎内部链接 </nuxt-link> 不起作用.

如何实现这个功能?

推荐答案

如果使用 locales

<nuxt-link 
  :to="localePath({ name: 'index', hash: '#anchor1'})" 
  v-text="Anchor 1" 
  alt="Anchor 1">
</nuxt-link>

其他

<nuxt-link to="/anchor1" v-text="Anchor 1" />

这篇关于Nuxt.js 和锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆