// 将 'to' 作为字符串传递
await navigateTo('/search')
// ... 或者作为路由对象
await navigateTo({ path: '/search' })
// 动态路由
await navigateTo({ path: '/post/'+permlink})
//post动态页面接受方法
const route = useRoute()
cosnt permlink = route.params.permlink
// ... 或者作为带有查询参数的路由对象
await navigateTo({
path: '/search',
query: {
page: 1,
sort: 'asc'
}
})
//serarch页面接受方法
const route = useRoute()
const query = route.query //用此方法接受参数
// 导航到外部URL
await navigateTo('https://nuxt.com', {external: true})
// 更全的设置
await navigateTo('https://nuxt.com', {
external: true,
open: {
target: '_blank',
windowFeatures: {
width: 500,
height: 500,
popup: true
}
}
})
RE: Nuxt开发指南