vue 使用input file点击上传本地图片

时间:2019-02-16 13:17:51   收藏:0   阅读:1659
<input type="file" @change="upData($event)" ref="InputFile" name="files" />
upData(event) {
            var reader = new FileReader();
            let fileData = this.$refs.InputFile.files[0];
            reader.readAsDataURL(fileData);
            let _this=this;
            reader.onload = function(e) {
                console.log(e)
                               // data定义字段
                _this.addimg=e.srcElement.result;
            };
        },

 

原文:https://www.cnblogs.com/chenchenhao/p/10387388.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!