【发布时间】:2020-04-24 01:39:54
【问题描述】:
我无法在编辑表单中显示旧图像。我已将上传的图像存储在 laravel 项目公共文件夹内的 img 文件夹中。以下是我用于保存和编辑表单数据的代码。如何以编辑形式显示旧上传的图像? 请帮帮我。
<input type="file" id="file-upload" @change="onFileChange" src="{{ asset('newapplicant.photo') }}">
脚本
save() {
const saveUrl = `/api/registration/${this.registrationId}/applicant`;
VueAxios.post(saveUrl, this.formData, {
headers: {
'X-Requested-With': 'XMLHttpRequest',
Authorization: `Bearer ${window.localStorage.getItem('token')}`,
},
}, {
timeout: 10000,
})
.then((response) => {
if (response.status === 200 || response.status === 201) {
this.applicant.push(response.data.data);
this.successfulMessage = 'Successful.';
this.clearAllData();
}
})
.catch((error) => {
console.log(`api error:${error}`);
});
},
edit(id) {
const url = `api/registration/${this.$route.params.regId}/applicant/${id}`;
VueAxios.get(url, {
headers: {
'X-Requested-With': 'XMLHttpRequest',
Authorization: `Bearer ${localStorage.getItem('token')}`,
},
}, {
timeout: 100000,
})
.then((response) => {
// debugger;
this.newapplicant = response.data.data;
});
},
【问题讨论】:
标签: vue.js