应用切到后台再返回会导致webview刷新的问题有人遇到过吗,比如webview调起摄像头拍照或者回到桌面在进入应用

7***@qq.com
- 发布:2025-06-11 18:34
- 更新:2025-06-13 16:56
- 阅读:50

7***@qq.com (作者)
uni代码
<template>
<view>
<web-view style="width: 100%;height:600rpx" src="http://192.168.2.254:5173/"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
webview代码
<template>
<img v-for="item in imgList" :src="item?.httpUrl" alt="">
<input type="file" @change="onFileChange">
</template>
<script setup>
import {ref} from "vue"
import axios from "axios"
const imgList = ref([])
const onFileChange = (e) => {
console.log(e.target.files[0])
let _formData = new FormData();
_formData.append("type", '现场照片');
_formData.append("file", e.target.files[0]);
axios.post('图片上传地址',_formData,{
headers:{
'Content-Type': 'multipart/form-data',
}
}).then(response => {
imgList.value.push(response.data.data)
console.log('上传成功:', response.data); // 处理成功响应
})
}
</script>
<style>
img{
width: 100px;
height: 100px;
}
</style>
7***@qq.com (作者)
下面回复提供了代码。 视频附件上传不了,有邮箱或者群吗
2025-06-13 16:50