小编Mat*_*leo的帖子

VueJS 路由/导航问题

使用 VueJS 时遇到问题(第一次使用)

  • 我在 doc root 的 index.html 文件中有 90% 的页面模板
  • 我有 3 个组件(每个组件都包含每个“页面”的主要内容正文)

我的路由器:

export default new Router({
  mode: 'history',
  hash: false,
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home
    },
    {
      path: '/gallery',
      name: 'Gallery',
      component: Gallery
    },
    {
      path: '/contact',
      name: 'Contact',
      component: Contact
    }
  ]
})
Run Code Online (Sandbox Code Playgroud)

我无法开始<router-link :to="{ name: 'Gallery' }">Gallery</router-link>工作 - 我的网站没有将它们呈现为我的 index.html 中的锚标记(我可能不明白如何/在哪里可以使用 Vue) - 所以我使用的是标准链接,例如<a class="nav-link" href="/gallery">Gallery</a>

问题:

虽然所有这些代码在我的本地机器上运行良好,但它在我上传代码的任何地方都不起作用(我想让它在 Netlify 上运行)。Netlify 和其他站点会覆盖我删除哈希的尝试,因此我的链接然后链接到例如

https://examplesite.com/#/ => https://examplesite.com/gallery#/

javascript vue.js vue-router netlify

0
推荐指数
1
解决办法
810
查看次数

标签 统计

javascript ×1

netlify ×1

vue-router ×1

vue.js ×1