我試圖去'www.mytargeturl.org'使用router.go,router.push,router.replace和window.location.href重定向我的vuejs應用程序,但我總是GET myVueapp.com/www.mytargeturl.org 這裏是我的路線:Vue2導航到外部URL與位置.href
routes:[
{path: '/', component: App,
children:[
{
path: 'detail',
component: ItemDetail,
props: true
},
{
path: 'search',
component: Middle
}
]
},
{
path: '/test', component: Test
},
{ path: '/a', redirect: 'www.mytargeturl.org' } // also tried this but didnt work
]
只需使用常規的'a'標籤。 vue-router用於在您的應用程序內導航 –
很簡單:不要使用vue-router,因爲它會重定向到內部鏈接(即在應用程序內)。使用'window.location',這應該工作得很好。 – Terry
我在發佈之前已經嘗試過window.location,但沒有成功。這裏是我的示例:https://jsfiddle.net/alvirtuoso/dkb1d13h/ – codely