Skip to content

Two svg-typed qr-codes in one page. Generates same qr-code for all two instances.  #2

@Humo8668

Description

@Humo8668

Type of qr-code must be "svg". For "canvas" type works correctly.
Moreover, settings of one reflects on another.

For this code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>QR Code Styling</title>
    <script type="text/javascript" src="https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js"></script>
</head>
<body>
<div id="qr_1" style="display: inline;"></div>
<div id="qr_2" style="display: inline;"></div>

<script type="text/javascript">

    const qrCode1 = new QRCodeStyling({
        width: 300,
        height: 300,
        type: "svg",
        data: "https://www.facebook.com/",
        image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
        dotsOptions: {
            color: "#4267b2",
            type: "rounded"
        },
        backgroundOptions: {
            color: "#e9ebee",
        },
        imageOptions: {
            crossOrigin: "anonymous",
            margin: 20
        }
    });
    
    const qrCode2 = new QRCodeStyling({
        width: 290,
        height: 290,
        type: "svg",
        data: "https://www.google.com/",
        dotsOptions: {
            color: "#4267b2",
            type: "rounded"
        },
        backgroundOptions: {
            color: "#e9ebee",
        },
        imageOptions: {
            crossOrigin: "anonymous",
            margin: 20
        }
    });

    qrCode1.append(document.getElementById("qr_1"));
    qrCode2.append(document.getElementById("qr_2"));
    //qrCode.download({ name: "qr", extension: "svg" });
</script>
</body>
</html>

Expected:
image

Got:
image

Sample:
https://jsfiddle.net/mz0kwdp2/13/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions