这可能很简单,但我已经查看了文档,但找不到任何关于它的信息。我想让我的'github‘链接重定向到github.com。然而,它只是将'https://github.com‘附加到我的url中,而不是跟随链接。下面是一个代码片段:
<BreadcrumbItem to='https://github.com'>
<Icon type="social-github"></Icon>
</BreadcrumbItem>
(这是对自定义CSS使用iView,但'to‘的工作方式与路由器链接相同)。
最终发生的是这样的:
发布于 2018-05-31 21:43:26
我阅读了Daniel的链接,并找到了一个解决方法:
{
path: '/github',
beforeEnter() {location.href = 'http://github.com'}
}
发布于 2018-09-18 14:14:53
<a :href="'//' + websiteUrl" target="_blank">
{{ url }}
</a>
发布于 2019-05-25 09:20:15
const github = { template: '<div>github</div>'}
const routes = [
{
path: '/github',
beforeEnter() {location.href = 'http://github.com'},
component: github
}
]
const router = new VueRouter({
routes
})
const app = new Vue({
router
}).$mount('#app')
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
<div id="app">
<li><router-link to="/github">github.com</router-link></li>
<router-view></router-view>
</div>
</body>
https://stackoverflow.com/questions/50633001
复制相似问题