Open chaijia opened 4 years ago
不跨域的就可以
不跨域的就可以
感觉很麻烦🤣
getImageToBase64 (url) { // 将外网图片url转为本地base64
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
try {
let axios = await import('axios')
axios = axios.default
const { data } = await axios.get(url, { responseType: 'blob', headers: { 'Access-Control-Allow-Origin': '*' } })
const reader = new FileReader()
reader.readAsDataURL(data)
reader.onloadend = function () {
const base64data = reader.result
resolve(base64data)
}
} catch (error) {
reject(error)
}
})
}
我用的这种方法
logoSrc想支持网络图片地址url