https://zhidao.baidu.com/question/1368028790248827179.html
<div class="content">
<input id="v_file" type="file" style="display:none;" onChange="play()"/>
<button id="play" onClick="yincang()">播放</button>
<video id="video_id" controls autoplay></video>
</div>
<script>
function yincang(){
var v_file=document.getElementById('v_file');
v_file.click();
}
function play(){
var file = document.getElementById('v_file').files[0];
var url = URL.createObjectURL(file);
console.log(url);
document.getElementById("video_id").src = url;
}
</script>
用display把input隐藏起来,然后注册一个click事件,这样就完成了你想要的功能。。
不知道我是不是理解错了你的需求
这个是你想要的答案吗
网友评论