gpt4 book ai didi

vue.js - Vue-router 附加相同的 URL

转载 作者:行者123 更新时间:2023-12-05 08:52:32 25 4
gpt4 key购买 nike

每当我尝试使用一个简单的

<router-link to="https://google.com">
Google
</router-link>

它呈现指向 http://localhost:8080/https:/google.com

的链接

router.js

export default new Router({
mode: 'history',
base: process.env.BASE_URL,
)}

而且我没有.env 文件。每当我创建 .env 并添加 BASE_URL=http://localhost:8080 时,它都会呈现 http://localhost:8080/http:/localhost:8080/https:/google.com

有人遇到过这个问题吗?

更新上面的示例反射(reflect)了外部网站,但内部链接也会发生这种情况。示例:

<router-link avatar :to="{name: 'author', params: {id: author.id, name: author.name}}"> foo </router-link>

定义作者的路线

{
path: '/author/:id/:name',
name: 'author',
component: Author
},

几天前一切正常,但一定有我添加的东西改变了这种行为。我到处都看了,但似乎找不到哪里出了问题。

最佳答案

是的,使用正常的 <a href=""></a>外部链接的 href 标签。 Vue-router 和 router-link 主要是为了实例资源。

关于vue.js - Vue-router 附加相同的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56567190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com