Front-end acquisition http path to the file

getFile: function(event){
	this.file = event.target.files[0];
	//获取图片http网上资源路径, 可以用于在浏览器上预览本地图片或者视频
	var windowURL = window.URL || window.webkitURL;
	this.pic_url = windowURL.createObjectURL(this.file);
}

Dynamic to the src attribute of the img tag assignment (vue.js)

<div class="user_pic" style="width:200px; height: 200px; margin-left:100px; margin-top:30px; float: left; border: 1px dashed #9D9D9D">
		<img v-if="pic_url!=''" style="width: 200px; height: 200px;" alt="" :src="pic_url">
		<p v-if="pic_url==''" style="margin-top: 45%; color: #9D9D9D">头像预览</p>
	</div>

: Src = "pic_url" vue binding properties of pic_url
Here Insert Picture Description

Published 63 original articles · won praise 1 · views 2655

Guess you like

Origin blog.csdn.net/qq_42039738/article/details/104736354