How to render QR code at center of the div in Vue platform
Syncfusion Vue Barcode control allows you to easily generate QR Codes in your application.
To render QR code at center of the div, we need to follow the below steps.
Step 1: Create QR Code using QrCodeGenerator
You can use the Syncfusion Barcode control’s QRCodeGenerator to generate a QR code.
Step 2: Add style to div
To center the QR Code add style to the div
.element {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Refer the code snippet below
App.vue
<template>
<div id="app" class="barcodeStyle">
<ejs-qrcodegenerator
id="barcode"
class="element"
ref="barcodeControl"
:width="width"
:height="height"
:displayText="displaytext"
:value="value"
:mode="mode"
></ejs-qrcodegenerator>
</div>
</template>
<style>
body {
margin-top: 100px;
}
.barcodeStyle {
height: 400px;
width: 400px;
background-color: #acf1e9;
position: absolute;
}
.element {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<script>
import { QRCodeGeneratorComponent } from '@syncfusion/ej2-vue-barcode-generator';
export default {
name: 'App',
components: {
'ejs-qrcodegenerator': QRCodeGeneratorComponent,
},
data() {
return {
width: '200px',
height: '200px',
displaytext: { text: 'Syncfusion' },
mode: 'SVG',
value: 'Syncfusion',
};
},
};
</script>
Refer to the working sample for additional details and implementation: Click here for sample
Conclusion
We hope you enjoyed learning about how to render QR code at center of the div in Vue platform.
You can refer to our Vue Barcode feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!