Commit 6fa418e4efe2f1da3ee9dc3fe077d3dd925281d1
1 parent
d6fa5a51
优化图片上传和显示
Showing
4 changed files
with
12 additions
and
8 deletions
src/api/driver/driver.js
src/components/ImageUpload/index.vue
| ... | ... | @@ -64,7 +64,7 @@ const number = ref(0); |
| 64 | 64 | const uploadList = ref([]); |
| 65 | 65 | const dialogImageUrl = ref(""); |
| 66 | 66 | const dialogVisible = ref(false); |
| 67 | -const baseUrl = import.meta.env.VITE_APP_BASE_API; | |
| 67 | +const baseUrl = ""; | |
| 68 | 68 | const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + props.uploadUrlSuffix); // 上传的图片服务器地址 |
| 69 | 69 | const headers = ref({ Authorization: "Bearer " + getToken() }); |
| 70 | 70 | const fileList = ref([]); |
| ... | ... | @@ -73,17 +73,17 @@ const showTip = computed( |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | 75 | watch(() => props.modelValue, val => { |
| 76 | + console.log("value=========>"+val); | |
| 77 | + | |
| 76 | 78 | if (val) { |
| 77 | 79 | // 首先将值转为数组 |
| 78 | 80 | const list = Array.isArray(val) ? val : props.modelValue.split(","); |
| 79 | 81 | // 然后将数组转为对象数组 |
| 80 | 82 | fileList.value = list.map(item => { |
| 83 | + console.log("111111111111111111111111"); | |
| 84 | + | |
| 81 | 85 | if (typeof item === "string") { |
| 82 | - if (item.indexOf(baseUrl) === -1) { | |
| 83 | - item = { name: baseUrl + item, url: baseUrl + item }; | |
| 84 | - } else { | |
| 85 | - item = { name: item, url: item }; | |
| 86 | - } | |
| 86 | + item = { name: item, url: item }; | |
| 87 | 87 | } |
| 88 | 88 | return item; |
| 89 | 89 | }); |
| ... | ... | @@ -174,6 +174,9 @@ function handleUploadError() { |
| 174 | 174 | |
| 175 | 175 | // 预览 |
| 176 | 176 | function handlePictureCardPreview(file) { |
| 177 | + console.log("file.url:"+file.url); | |
| 178 | + console.log(file); | |
| 179 | + | |
| 177 | 180 | dialogImageUrl.value = file.url; |
| 178 | 181 | dialogVisible.value = true; |
| 179 | 182 | } | ... | ... |
src/utils/request.js