How to use the qrcode/build/qrcode.toDataURL function in qrcode

To help you get started, we’ve selected a few qrcode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fengyuanchen / vue-qrcode / src / index.js View on Github external
generate() {
      const { options, tag } = this;
      const value = String(this.value);

      if (tag === 'canvas') {
        QRCode.toCanvas(this.$el, value, options, (error) => {
          /* istanbul ignore if */
          if (error) {
            throw error;
          }
        });
      } else if (tag === 'img') {
        QRCode.toDataURL(value, options, (error, url) => {
          /* istanbul ignore if */
          if (error) {
            throw error;
          }

          this.$el.src = url;
        });
      } else {
        QRCode.toString(value, options, (error, string) => {
          /* istanbul ignore if */
          if (error) {
            throw error;
          }

          this.$el.innerHTML = string;
        });