
- 点击Vue图标,选择电脑中图片,选中后把图片替换为选中图片
- 点击上传,通过文件流的方式把图片上传至服务器,服务器将图片保存至指定位置,并根据时间生成指定名称,上传成功,返回新生成文件名。
- 服务器自定义接口,通过需要的文件名,返回指定文件流
- 上传图片成功后,在旁边显示上传成功的图片
- 点击Vue图标,选择电脑中图片,选中后把图片替换为选中图片:
<template>
<div>
<img :src="f.src" width="100px" height="100px" v-if="f" />
<img src="../assets/logo.png" @click="add()" width="100px" height="100px" v-else />
<input
class="value"
style="display:none"
type="file"
ref="file"
accept="image/*"
multiple="multiple"
@change="getFile($event)"
/>
<span @click="submitForm($event)">上传</span>
<img :src="loadImage" width="100px" height="100px" />
</div>
</template>
import axios from "axios";
export def