uniapp中实现跳转链接到游览器(安卓-h5)

uniapp中实现跳转链接到游览器(安卓-h5)

项目中需要做到跳转到外部链接,网上找了很多都不是很符合自己的要求,需要编译成app后是跳转到游览器打开链接,编译成web是在新窗口打开链接。实现的代码如下:

效果:


代码:

js 复制代码
wxParseATap(e) {
				const {
					href
				} = e.currentTarget.dataset; // TODO currentTarget才有dataset
				if (!href) return;
				let parent = this.$parent;
				while (!parent.preview || typeof parent.preview !== 'function') { // TODO 遍历获取父节点执行方法
					parent = parent.$parent;
				}
				// parent.navigate(href, e);
				// #ifdef APP-PLUS
				plus.runtime.openURL(href);
				// #endif

				// #ifdef H5
				window.open(href);
				// #endif

				// #ifdef MP
				uni.setClipboardData({
					data: href,
					success: () => {
						uni.showToast({
							icon: 'none',
							title: '链接已复制,请在浏览器打开'
						});
					}
				});
				// #endif
			},
相关推荐
橘子编程13 小时前
UniApp跨端开发终极指南
开发语言·vue.js·uni-app
叱咤少帅(少帅)3 天前
Uniapp开发pc端,小程序和APK
小程序·uni-app
2501_915918413 天前
iOS性能测试工具 Instruments、Keymob的使用方法 不局限 FPS
android·ios·小程序·https·uni-app·iphone·webview
2501_915918414 天前
iOS 混淆流程 提升 IPA 分析难度 实现 IPA 深度加固
android·ios·小程序·https·uni-app·iphone·webview
前端 贾公子4 天前
解决uni-app 输入框,键盘弹起时页面整体上移问题
前端·vue.js·uni-app
Muchen灬4 天前
【uniapp】(5) 创建gitee仓库并推送源码
gitee·uni-app
Muchen灬4 天前
【uniapp】(6) uniapp中使用vuex
uni-app
2501_915909064 天前
React Native 上架 App Store:项目运行与审核构建的流程
android·ios·小程序·https·uni-app·iphone·webview
李庆政3704 天前
uniapp+unicloud打包部署微信小程序
微信小程序·小程序·uni-app