Created
April 23, 2025 11:38
-
-
Save qichunren/bf68a5bd4f2f6285e3611935f0fce4a5 to your computer and use it in GitHub Desktop.
Frontend Javascript Generate QRCode
This file contains hidden or 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
import QRCode from 'qrcode' | |
document.addEventListener('DOMContentLoaded', function() { | |
console.log("DOMContentLoaded"); | |
const baseUrl = "https://open.weixin.qq.com/connect/oauth2/authorize"; | |
const params = new URLSearchParams({ | |
appid: "wx49e1457a970ee840", | |
redirect_uri: "https://qiwangtech.com/weixin/wechat/verify", | |
response_type: "code", | |
scope: "snsapi_base", | |
state: "STATE" | |
}); | |
const wechatAuthUrl = `${baseUrl}?${params.toString()}#wechat_redirect`; | |
QRCode.toCanvas(document.getElementById('qrcode'), wechatAuthUrl, function (error) { | |
if (error) console.error(error) | |
console.log('success!'); | |
}) | |
}); |
Author
qichunren
commented
Apr 23, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment