Skip to content

Commit b09d142

Browse files
authored
Update image.vue
修复上传图片组件bug
1 parent e102f82 commit b09d142

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web/src/components/upload/image.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<el-upload
1414
class="image-uploader"
1515
:action="`${path}/fileUploadAndDownload/upload`"
16+
:headers="{ 'x-token': token }"
1617
:show-file-list="false"
1718
:on-success="handleImageSuccess"
1819
:before-upload="beforeImageUpload"
@@ -25,6 +26,7 @@
2526
</template>
2627
<script>
2728
const path = process.env.VUE_APP_BASE_API;
29+
import { mapGetters } from "vuex";
2830
import ImageCompress from "@/utils/image.js";
2931
export default {
3032
name: "upload-image",
@@ -51,6 +53,9 @@ export default {
5153
path: path,
5254
};
5355
},
56+
computed: {
57+
...mapGetters("user", ["userInfo", "token"]),
58+
},
5459
methods: {
5560
beforeImageUpload(file) {
5661
let isRightSize = file.size / 1024 < this.fileSize;
@@ -65,7 +70,7 @@ export default {
6570
// this.imageUrl = URL.createObjectURL(file.raw);
6671
const { data } = res;
6772
if (data.file) {
68-
this.$emit("change", data.file.url);
73+
this.$emit("change", this.path + data.file.url);
6974
}
7075
},
7176
},
@@ -97,4 +102,4 @@ export default {
97102
height: 178px;
98103
display: block;
99104
}
100-
</style>
105+
</style>

0 commit comments

Comments
 (0)