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

vue 2.7 vue-qrcode 2.2.0 #164

Open
pigping88 opened this issue Sep 5, 2023 · 8 comments
Open

vue 2.7 vue-qrcode 2.2.0 #164

pigping88 opened this issue Sep 5, 2023 · 8 comments

Comments

@pigping88
Copy link

the demo:

<vue-qrcode
value="https://www.1stg.me"
@change="onDataUrlChange"
/>

<script> import VueQrcode from 'vue-qrcode' export default { data() { return { dataUrl: null, } }, components: { VueQrcode, }, methods: { onDataUrlChange(dataUrl) { this.dataUrl = dataUrl }, }, } </script>

the error:
[Vue warn]: Missing required prop: "color"
Vue warn]: Missing required prop: "type"

change demo:

data() {
return {
qrcode: {
color: {
dark: 'black', // 设置二维码的主要颜色
light: 'white' // 设置二维码的背景颜色
}
},
codeText: 'test qrcode text',
no error, but there is no a qrcode in the page

@syafiqmuda
Copy link

syafiqmuda commented Oct 11, 2023

Hello, for the v2.2.0, can I do like this instead?

<VueQrcode value="Let me be" type="image/png" color="{ dark: '#000000ff', light: '#ffffffff' }" @change="onDataUrlChange" />

@JounQin
Copy link
Member

JounQin commented Oct 11, 2023

Hello, for the v2.2.0, can I do like this instead?

<VueQrcode value="Let me be" type="image/png" color="{ dark: '#000000ff', light: '#ffffffff' }" @change="onDataUrlChange" />

Sure, does anything work unexpectedly?

@syafiqmuda
Copy link

Hello, for the v2.2.0, can I do like this instead?
<VueQrcode value="Let me be" type="image/png" color="{ dark: '#000000ff', light: '#ffffffff' }" @change="onDataUrlChange" />

Sure, does anything work unexpectedly?

I dont know what happen, but it seem the QR wont appear, even copying directly from demo, doesnt do anything. there is no error being display, also when I inspect the element, it show 0x0 size.

@JounQin
Copy link
Member

JounQin commented Oct 13, 2023

Can you provide an online reproduction?

@JounQin

This comment was marked as off-topic.

@rx-ts rx-ts deleted a comment Nov 22, 2023
@susnux
Copy link

susnux commented Feb 9, 2024

For Vue 2.7 this part of the code is invalid:

h('img', {
...attrs,
src: dataUrlRef.value,
})

For Vue 2.7 it must look like this:

 h('img', { 
   attrs: { ...attrs, src: dataUrlRef.value },
 }) 

@JounQin
Copy link
Member

JounQin commented Feb 9, 2024

@susnux Interesting, would you like to raise a PR for it?

@susnux
Copy link

susnux commented Feb 9, 2024

Probably something like this is needed:

const version = Number(Vue.version.split('.')[0])

if (version === 2) {
  // Vue v2 code
} else {
  // current code
}

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

4 participants