通常当您使用输入字段上传图像时:
<div class="custom-file">
<input type="file" class="custom-file-input" id="image" ref="image" accept="image/png, image/jpeg">
<label class="custom-file-label" for="image">Choose file...</label>
</div>
您可以通过以下方式访问该文件:
this.$refs.image.files[0]
但是,如果我希望在不使用上传弹出表单的情况下动态更改 this.$refs.image.files[0] 会发生什么?
我试过这个:
this.$refs.image = window.location.protocol + '//' + window.location.hostname + '/storage/images/image-gallery/' + imageUrl;
这个
this.$refs.image.src = window.location.protocol + '//' + window.location.hostname + '/storage/images/image-gallery/' + imageUrl;
但它失败了,知道如何破解这个吗?
谢谢