hilongjw / vue-lazyload

A Vue.js plugin for lazyload your Image or Component in your application.
http://hilongjw.github.io/vue-lazyload/
MIT License
7.99k stars 865 forks source link

img.crossorigin = 'anonymous' #509

Closed AceLing closed 1 year ago

AceLing commented 1 year ago

Thanks for your code. It's pretty great!

I have a question ahout in setting attribute named 'crossorigin'

Pls help me. I am grateful for your efforts.

AceLing commented 1 year ago

I find out the correct way to solve this. (Here is the commit I find: feat: add cors https://github.com/hilongjw/vue-lazyload/commit/e9c4a10314d27d9d5e914756853aa4f36d9a95ca)

Set the HTML Img Element crossorigin="anonymous"

<img v-lazy="defaultThumb" crossorigin="anonymous" />

And add a attribute named 'cors'

{
  // lazyComponent: ...,
  // error: ...,
  // loading: ...,
  filter: {
    imgFormat(img) {
      img.cors = 'anonymous';
    },
  },
}

Again, I am grateful for your efforts.