67 lines
1.7 KiB
Vue
67 lines
1.7 KiB
Vue
<template>
|
|
<view class="container">
|
|
<navBar :title="title"></navBar>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from "vue";
|
|
import { onLoad } from "@dcloudio/uni-app";
|
|
import navBar from "@/components/navBar/navBar.vue";
|
|
const title = ref("新闻详情");
|
|
const safeUrl = ref("");
|
|
|
|
onLoad((query) => {
|
|
// 兼容编码后的 url
|
|
const raw = query && (query.url || "");
|
|
try {
|
|
safeUrl.value = decodeURIComponent(raw);
|
|
title.value = query.title;
|
|
// #ifdef APP-PLUS
|
|
let wv = plus.webview.create("", "custom-webview", {
|
|
top: "140rpx",
|
|
bottom:"20rpx",
|
|
|
|
});
|
|
wv.loadURL( safeUrl.value);
|
|
|
|
let pages = getCurrentPages();
|
|
let page = pages[pages.length - 1];
|
|
|
|
var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
|
|
currentWebview.append(wv);
|
|
setTimeout(function () {
|
|
wv = currentWebview.children()[0];
|
|
uni.getSystemInfo({
|
|
//成功获取的回调函数,返回值为系统信息
|
|
success: (sysinfo) => {
|
|
|
|
let height = sysinfo.windowHeight; //自行修改,自己需要的高度 此处如底部有其他内容,可以直接---(-50)这种
|
|
wv.setStyle({ top: 70,height: height- 70});
|
|
},
|
|
complete: () => {}
|
|
});
|
|
|
|
}, 300); //如果是页面初始化调用时,需要延时一下
|
|
wv.onloaded = (e) => {
|
|
wv.show();
|
|
};
|
|
// #endif
|
|
} catch (e) {
|
|
safeUrl.value = raw;
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.container {
|
|
height: 100vh;
|
|
overflow: scroll;
|
|
}
|
|
.tip {
|
|
padding: 24rpx;
|
|
color: #666;
|
|
font-size: 28rpx;
|
|
}
|
|
</style>
|