options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
修改为:
if(response.imgUrl.indexOf('http://')>-1){
options.img = response.imgUrl;
}else{
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
}
const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar;
改为:
// 判断是否包含 http 或 https,如果有则直接使用,否则拼接完整的地址。
if (response.imgUrl.startsWith('http://') || response.imgUrl.startsWith('https://')) {
options.img = response.imgUrl;
} else {
const baseApi = import.meta.env.VITE_APP_BASE_API || '';
options.img = baseApi + response.imgUrl;
}
//判断是否包含http,如果有则直接使用,否则拼接完整的地址。
if (picUrl.startsWith("http")) {
picUrl = res.fileName;
} else {
picUrl = import.meta.env.VITE_APP_BASE_API + res.fileName;
}
//判断头像是否包含http,如果有则直接使用,否则拼接完整的地址。
const avatar = (user.avatar == "" || user.avatar == null) ? defAva :
(user.avatar.startsWith('http') ? user.avatar : import.meta.env.VITE_APP_BASE_API + user.avatar);