Files
OpenAuth.Net/docs/pro/openurl.md

30 lines
788 B
Markdown
Raw Normal View History

2023-08-11 17:47:02 +08:00
# 打开指定URL
上一章节通过添加模块或直接在路由表中添加固定路由实现路由控制。在有些场景下需要代码中直接打开一个外部指定URL的地址不通过系统的【模块管理】功能添加到导航栏如下图
2025-04-10 10:35:54 +08:00
![2025-04-10-10-34-19](http://img.openauth.net.cn/2025-04-10-10-34-19.png)
2023-08-11 17:47:02 +08:00
可以直接使用下面代码实现:
```javascript
2025-04-10 10:35:54 +08:00
const openUrl = () => {
const routes = router.getRoutes()
routes.forEach(route => {
if (route.path === '/redirect/iframe') {
route.meta.title = 'OpenAuth.Net官网' // 设置标题
2023-08-11 17:47:02 +08:00
}
2025-04-10 10:35:54 +08:00
})
router.push({
path: '/redirect/iframe',
query: {
url: encodeURIComponent(`http://www.openauth.net.cn`) // 设置URL
}
})
}
2023-08-11 17:47:02 +08:00
```