以下是uniapp开发app时使用webview嵌入兔小巢实现反馈渠道的方法
通过传递登录态实现默认登录,对应文档地址
注意,这里使用的是自定义头部,所以设置安全高度和窗体高度话也需要注意,代码中的60是指自定义头部的高度
<template>
<view style="height:60rpx">自定义头</view>
<web-view :src="src"></web-view>
</template>
<script setup>
import { onLoad } from "@dcloudio/uni-app";
import { ref, computed } from "vue";
import isImg from "@/static/images/mine/default_avatar.png";
const src = ref("");
const wv = ref(null);
onLoad(async () => {
/*#ifdef APP-PLUS*/
let height = 0; //定义动态的高度变量
let statusbar = 0; // 动态状态栏高
uni.getSystemInfo({
// 获取当前设备的具体信息
success: (sysinfo) => {
statusbar = sysinfo.statusBarHeight + 60;
height = sysinfo.windowHeight - sysinfo.statusBarHeight - 60;
},
});
setTimeout(() => {
const pages = getCurrentPages();
wv.value = pages[pages.length - 1].$getAppWebview().children()[0];
wv.value.setStyle({
top: statusbar,
height: height,
});
}, 200);
/*#endif*/
src.value = `https://support.qq.com/products/12345?nickname=哈哈哈&avatar=${isImg}&openid=123`;
});
</script>
<style scoped lang="scss"></style>