使用 VueJS 时遇到问题(第一次使用)
我的路由器:
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#/