<input type="file" >
<div class="add_img">
上传图片
<input type="file" id="addFile" onchange="getAddImg('addFile')">
</div>
<div id="add_msg" style="100%">
<img id="img" src="" alt="">
</div>
<script type="text/javascript">
function getAddImg(obj){
alert("asdasd")
let docObj = document.getElementById(obj);
let img = document.getElementById("img");
let objMsg = document.getElementById("add_msg");
let file = docObj.files;
console.log(file[0])
objMsg.append("<p>"+file[0].name+"</p>")
if(file && file[0]){
let src = window.URL.createObjectURL(file[0]);
img.src = src;
}else{
}
}
</script>
机型:VIVO IQOO
微信版本号:version 8.0.6
代码:
<input type="file" >
<div class="add_img">
上传图片
<input type="file" id="addFile" onchange="getAddImg('addFile')">
</div>
<div id="add_msg" style="100%">
<img id="img" src="" alt="">
</div>
<script type="text/javascript">
function getAddImg(obj){
alert("asdasd")
let docObj = document.getElementById(obj);
let img = document.getElementById("img");
let objMsg = document.getElementById("add_msg");
let file = docObj.files;
console.log(file[0])
objMsg.append("<p>"+file[0].name+"</p>")
if(file && file[0]){
let src = window.URL.createObjectURL(file[0]);
img.src = src;
}else{
}
}
</script>
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)