【发布时间】:2020-05-03 21:41:10
【问题描述】:
我正在尝试使用fingerprintjs2 来识别设备。但是,我是使用库的新手,我收到错误 Uncaught ReferenceError: Fingerprint2 is not defined。
这是我的代码:
<script src="https://github.com/Valve/fingerprintjs2"></script>
<script>
if (window.requestIdleCallback) {
requestIdleCallback(function () {
Fingerprint2.get(function (components) {
console.log(components) // an array of components: {key: ..., value: ...}
})
})
} else {
setTimeout(function () {
Fingerprint2.get(function (components) {
console.log(components) // an array of components: {key: ..., value: ...}
})
}, 500)
}
</script>
谁能告诉我为什么这不起作用?我已经为此安装了纱线。
这不是使用 javascript 库的正确方法吗?
另外,请告诉我是否有任何替代记忆设备的方法,但是,据我进行一些研究,似乎没有。
编辑:
我现在认为这可能与 CORS 有关,因为它会发出警告:Cross-Origin Read Blocking (CORB) blocked cross-origin response https://cdnjs.com/libraries/fingerprintjs2 with MIME type text/html
【问题讨论】:
-
使用
https://cdnjs.com/libraries/fingerprintjs2而不是github url -
它仍然给出同样的错误