图片上传

This commit is contained in:
2023-04-28 10:16:19 +08:00
parent c5b056b5a4
commit ea9974862e
2 changed files with 19 additions and 3 deletions

View File

@@ -19,12 +19,13 @@
</div>
<div>上传图片</div>
<el-upload
action="https://jsonplaceholder.typicode.com/posts/"
action="http://localhost:8080/common/uploadOSS"
:headers="headers"
list-type="picture-card"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
:on-success="handleSuccess"
>
<!-- :headers="headers"-->
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible">
@@ -49,6 +50,7 @@
import AMapLoader from "@amap/amap-jsapi-loader";
import {getStation} from "@/api/pile/station.js";
import bus from "@/bus/bus";
import {getToken} from "@/utils/auth";
window._AMapSecurityConfig = {
securityJsCode: "829b6b73f84682c2eb982eaa47a745b8",
@@ -75,9 +77,17 @@ export default {
placeSearch: "",
stationId: this.$route.params.id,
avatar: "",
headers: {
Authorization: "Bearer " + getToken()
},
imageUrl: null
};
},
methods: {
handleSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw);
console.log("图片上传成功 url", this.imageUrl);
},
handleRemove(file, fileList) {
console.log(file, fileList);
},