html部分
<input type="file" id="file1" accept="image/*" capture="camera" @change="changePic" />
<!-- accept="video/*" 可调用摄像头拍摄视频 -->
js部分
changePic(e) {
// console.log(e)
const _this = this;
const fileObj = e.target;
const file = fileObj.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(e) {
const imgResult = e.target.result;
// 可预览的图片地址
_this.imgResult = imgResult;
};
}