Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能用网络图片作为logo图片吗? #74

Open
chaijia opened this issue Apr 28, 2020 · 3 comments
Open

能用网络图片作为logo图片吗? #74

chaijia opened this issue Apr 28, 2020 · 3 comments

Comments

@chaijia
Copy link

chaijia commented Apr 28, 2020

logoSrc想支持网络图片地址url

@Binaryify
Copy link
Owner

不跨域的就可以

@guygubaby
Copy link

不跨域的就可以

感觉很麻烦🤣

@guygubaby
Copy link

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)
        }
      })
    }

我用的这种方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants