-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b2a466
commit 3c34f8e
Showing
2 changed files
with
74 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
<template> | ||
<span> | ||
<vue-qr | ||
class="qr-item" | ||
:text="this.field.value" | ||
:size="this.field.indexSize" | ||
:bgSrc="this.field.background" | ||
:logoSrc="this.field.logo" | ||
:margin="this.field.margin" | ||
></vue-qr> | ||
<div ref="qrContainer" class="qr-item"></div> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
import VueQr from 'vue-qr/src/packages/vue-qr.vue' | ||
import { AwesomeQR } from 'awesome-qr'; | ||
export default { | ||
props: [ | ||
'resourceName', | ||
'field' | ||
'resourceName', | ||
'field' | ||
], | ||
components: { | ||
VueQr | ||
} | ||
} | ||
</script> | ||
mounted() { | ||
this.generateQRCode(); | ||
}, | ||
methods: { | ||
async generateQRCode() { | ||
const qrCode = new AwesomeQR({ | ||
text: this.field.value, | ||
size: this.field.indexSize, | ||
margin: this.field.indexSize > 250 ? this.field.margin : 1, | ||
backgroundImage: this.field.background || null, | ||
logoImage: this.field.logo || null, | ||
logoMargin: this.field.indexSize > 250 ? 10 : 0, | ||
}); | ||
<style> | ||
.qr-item{ | ||
margin-top: 5px; | ||
} | ||
.qr-item img{ | ||
border: solid thin #ddd; | ||
padding: 2px; | ||
const qrCodeImage = await qrCode.draw(); | ||
this.$refs.qrContainer.innerHTML = `<img src="${qrCodeImage}" alt="${this.field.value}" />`; | ||
} | ||
} | ||
} | ||
</style> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters