0
点赞
收藏
分享

微信扫一扫

uniapp webview网页返回

七千22 2022-04-23 阅读 91
<template>
	<view class="content">
		<web-view :src="url"></web-view>
	</view>
</template>

<script>
	
	var wv;//计划创建的webview
	export default {
		data() {
			return {
				url: 'https://www.baidu.com/',
				canBack: false,
			}
		},
		onLoad() {
		
		},
		methods: {
		},
		
		onBackPress(options) {
			//let h = plus.webview.getWebviewById(wv.id)
			//let url = h.getURL()
			let url = wv.getURL()
			wv.back();
			return true; //不返回提示再按一次退出应用
		},
		onReady() {
			// #ifdef APP-PLUS
			let currentWebview = this.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
			setTimeout(function() {
				wv = currentWebview.children()[0]
			}, 1000); //如果是页面初始化调用时,需要延时一下
			// #endif
		}
	};
</script>

<style>
	
</style>
举报

相关推荐

0 条评论