1.vue3中使用qrcodejs2 报错,如下:
TypeError:Cannot read properties of undefined(reading‘_android‘)
解决办法,使用qrcodejs2-fix
替换qrcodejs2
npm install qrcodejs2-fix
const getQRCode = text => {
const qrcode = new QRCode('qrcode', {
text,
width: 240,
height: 240,
colorDark: '#000000', //二维码颜色
colorLight: '#ffffff', //二维码背景色
correctLevel: QRCode.CorrectLevel.L //容错率,L/M/H})
})
return qrcode.value
}
2. worker-src 相关错误
错误一:Content Security Policy directive: "worker-src 'self' 'unsafe-inline' 'unsafe-eval'".
解决办法:
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval'; worker-src 'self' 'unsafe-inline' 'unsafe-eval';" />
错误二:
chunk-AUZ3RYOM.js?v=6721342e:18 Refused to create a worker from 'blob:http://localhost:5173/db0070e0-ccfd-4c58-a15c-68fc6ddc32c8' because it violates the following Content Security Policy directive: "worker-src 'self' 'unsafe-inline' 'unsafe-eval'".
main.ts:49 DOMException: Failed to construct 'Worker': Access to the script at 'blob:http://localhost:5173/db0070e0-ccfd-4c58-a15c-68fc6ddc32c8' is denied by the document's Content Security Policy.
at http://localhost:5173/node_modules/.vite/deps/agora-rtm-sdk.js?v=6721342e:17285:560
at http://localhost:5173/node_modules/.vite/deps/agora-rtm-sdk.js?v=6721342e:9:85
at node_modules/agora-rtm-sdk/index.js (http://localhost:5173/node_modules/.vite/deps/agora-rtm-sdk.js?v=6721342e:10:6)
at __require2 (http://localhost:5173/node_modules/.vite/deps/chunk-AUZ3RYOM.js?v=6721342e:18:50)
at http://localhost:5173/node_modules/.vite/deps/agora-rtm-sdk.js?v=6721342e:21093:16
解决办法:添加 bolb:
<meta http-equiv="Content-Security-Policy" content="worker-src 'self' blob:;">
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。