2020-08-10 web 上传本地图片预览的方法

2020-08-10  本文已影响0人  遗忘的灬誓言

input 给上@change事件,调用OpenUpload方法

    OpenUpload(e) {
                let files = e.target.files[0];
                let url = "";
                let reader = new FileReader();
                reader.readAsDataURL(files)
                let that = this;
                reader.onload = function() {
                    url = this.result.substring(this.result.indexOf(",") + 1);
                    that.upload_imgurl = "data:image/png;base64," + url;
                }
            },
上一篇 下一篇

猜你喜欢

热点阅读