<template>
	<view>
		<web-view ref="webview" :src="xurl" :update-title="true" :webview-styles="webviewStyles"  @message="getMessage"></web-view>
	</view>
</template>


<script>
	var wv;//计划创建的webview
	export default {
		data() {
			return {
				xurl: '',
				old_url:'',
				webviewStyles: {
									progress: {
										color: '#FF3333'
									}
								},
			};
		},
		onReady() {

		},
		onLoad(option) {
			//数据
			var _this =this;
			var url = option.url;
			var title = option.title;
			if(_this.$com.isNull(url))
			{
				uni.navigateBack({
					delta:1,
				})
			}
			_this.old_url = url;
			_this.xurl = decodeURIComponent(url);
			if(!_this.$com.isNull(title))
			{
				var pageTitle = title;
			}
			else
			{
				var pages = getCurrentPages();
				var page = pages[pages.length - 1];
				// #ifndef APP-PLUS
				var pageTitle  = page.$page.meta.navigationBar.titleText;
				// #endif
				 
				// #ifdef APP-PLUS
				var webView = currentPage.$getAppWebview();
				var pageTitle  = webView.getStyle().name;
				// #endif

				if(_this.$com.isNull(pageTitle))
				{
					pageTitle = 'webview';
				}
			}
			uni.setNavigationBarTitle({
				title:pageTitle,
			})
			
		},
		methods: {
			getMessage(event) {
				// #ifdef APP-PLUS
				console.log('event', event);
				// #endif
			},
		},
	};
</script>

<style>

</style>
