UniApp Webview 中使用 $router.resolve 打开新页面
在 UniApp 的 Webview 中也可以使用类似于 Web 端的代码来打开一个新的页面或链接。您可以将以下代码添加到您的 UniApp 页面中:
let path = '/your/path'; // 您想要打开的页面路径
let query = { node_id: this.selected_node_id, type: this.created_type }; // 您想要传递的查询参数
let routeData = this.$router.resolve({ path, query }); // 使用 $router.resolve 方法获取路由信息
let href = routeData.href; // 获取路由信息中的链接地址
window.open(href, '_blank'); // 在新窗口中打开链接
请注意,您需要先在 UniApp 中使用 Vue Router 进行路由配置,以便在使用 $router.resolve 方法时获取正确的路由信息。
AI 优化版
原文地址:https://www.cveoy.top/t/topic/outV 著作权归作者所有。请勿转载和采集!