Binaryify / vue-qr

The Vue Component for Awesome-qr.js
MIT License
849 stars 123 forks source link

:bgSrc :logoSrc 两属性直接赋值"http://xxxxx.png"会报跨域问题 #24

Closed tustman closed 5 years ago

tustman commented 6 years ago

Access to Image at 'http://xxx.yyyyyyyy.com/app/package/2ec8bab90c794f208b6c2137a50dd9db.png' from origin 'http://localhost:9527' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9527' is therefore not allowed access.

如果直接使用img标签可以展示出图片 <img src="http://xxx.yyyyyyyy.com/app/package/2ec8bab90c794f208b6c2137a50dd9db.png">

xiaoshengxianjun commented 6 years ago

对啊,这个问题怎么解决?求方案

tustman commented 6 years ago

@xiaoshengxianjun 建议你用下面这个试试 import Qrcanvas from 'qrcanvas-vue'

const image = new Image() image.src = this.currentLogo image.onload = () => { this.options = Object.assign({}, this.options, { data: 'http://www.xxxxx.png', cellSize: 8, size: 300, logo: { image } }) }

ShingWalker commented 6 years ago

@tustman 你是怎么处理的?

tustman commented 6 years ago

@19L 看我上面的留言, 我是换用了另外一个二维码组件解决的问题,

import Qrcanvas from 'qrcanvas-vue'

const image = new Image()
image.src = this.currentLogo
image.onload = () => {
    this.options = Object.assign({}, this.options, {
        data: 'http://www.xxxxx.png',
        cellSize: 8,
        size: 300,
        logo: {
        image
        }
    })
}
Binaryify commented 6 years ago

试试新版本

holyliar commented 5 years ago

最新版本也没能解决这个问题啊?这个问题为了兼容性暂时是不会解决吗?

javascripet commented 5 years ago

试试新版本

还是不行哟...

whenevery commented 5 years ago

为什么 一定需要发起http请求 获取文件呢? 是需要获取特定的属性吗 可以做直接加载获取文件信息吗? https域名里使用http的logo 固定会报错 (某些外部资源就是http的

Binaryify commented 5 years ago

@whenevery 加载就是要请求,用代理吧

Binaryify commented 5 years ago

@hanniba214 @javascripet 用代理,前端只能解决 canvas 图片被污染的问题,但是无法处理跨域问题

DongJigong commented 5 years ago

这个问题还没解决么?

Binaryify commented 5 years ago

@DongJigong 图片服务器端得支持 CORS,不然没用,要么就套一层图片代理 https://developer.mozilla.org/zh-CN/docs/Web/HTML/CORS_enabled_image

DongJigong commented 5 years ago

@DongJigong 图片服务器端得支持 CORS,不然没用,要么就套一层图片代理 https://developer.mozilla.org/zh-CN/docs/Web/HTML/CORS_enabled_image

好的.

Vitomir2 commented 1 year ago

How the is accepting such url without problems, but the vue-qr is not ?