Na verdade não é.
*O que precisa hoje em dia é importar uma biblioteca.
*
-
E fazer um codigo personalizado.*
const QRModule = {
_qr: null,
_container: null,
_websiteEl: null,
_debounce: null,init() {
this._container = document.getElementById('card-qrcode');
this._websiteEl = document.querySelector('[data-field="website"]');if (!this._container || !this._websiteEl) return; // Verifica se a lib foi carregada if (typeof QRCode === 'undefined') { console.warn('QRCode.js não carregado.'); return; } // Gera com o valor atual (já pode ter sido restaurado pelo Editor) this._generate(this._websiteEl.textContent.trim()); // Atualiza ao perder o foco (salvo) this._websiteEl.addEventListener('blur', () => { this.update(this._websiteEl.textContent.trim()); }); // Atualiza enquanto digita (debounced) this._websiteEl.addEventListener('input', () => { clearTimeout(this._debounce); this._debounce = setTimeout(() => { this.update(this._websiteEl.textContent.trim()); }, 500); });},
/** Normaliza texto para URL válida */
_toUrl(text) {
const t = (text || '').trim();
if (!t) return 'https://example.com';
return /^https?:///i.test(t) ? t :https://${t};
},_generate(text) {
if (!this._container || typeof QRCode === 'undefined') return;// Limpa instância anterior this._container.innerHTML = ''; this._qr = null; try { this._qr = new QRCode(this._container, { text: this._toUrl(text), width: 62, height: 62, colorDark: '#191b26', colorLight: '#ffffff', correctLevel: QRCode.CorrectLevel.M }); } catch (e) { console.warn('Erro ao gerar QR code:', e); }},