jsy-app/pages/common/webview/index.vue

50 lines
1.1 KiB
Vue
Raw Normal View History

2024-09-18 10:30:10 +08:00
<template>
<custom-nav-bar :left="true" :title="params.title" />
<view v-if="params.url">
2025-02-07 16:16:29 +08:00
<web-view style="margin-top: 45px;" :webview-styles="webviewStyles" :src="`${params.url}`"></web-view>
</view>
2024-09-18 10:30:10 +08:00
</template>
<script>
2025-01-07 16:53:03 +08:00
var wv; //计划创建的webvie
export default {
data() {
return {
params: {},
webviewStyles: {
progress: {
color: "#FF3333"
}
}
}
},
props: {
src: {
type: [String],
default: null
}
},
onLoad(event) {
this.params = event
2025-01-06 16:56:41 +08:00
// if (event.title) {
// uni.setNavigationBarTitle({
// title: event.title
// })
// }
2025-01-07 16:53:03 +08:00
},
onReady() {
2025-02-07 16:16:29 +08:00
uni.showLoading()
2025-01-07 16:53:03 +08:00
// #ifdef APP-PLUS
//此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
var currentWebview = this.$scope.$getAppWebview()
setTimeout(function() {
wv = currentWebview.children()[0]
wv.setStyle({
2025-02-07 16:16:29 +08:00
top: 70
2025-01-07 16:53:03 +08:00
})
2025-02-07 16:16:29 +08:00
uni.hideLoading()
}, 500); //如果是页面初始化调用时,需要延时一下
2025-01-07 16:53:03 +08:00
// #endif
}
}
</script>