代码如下:
<script>
const fpPromise = new Promise((resolve, reject) => {
const script = document.createElement('script')
script.onload = resolve
script.onerror = reject
script.async = true
script.src = 'https://cdn.jsdelivr.net/npm/'
+ '@fingerprintjs/fingerprintjs@3/dist/fp.min.js'
document.head.appendChild(script)
})
.then(() => FingerprintJS.load())
// Get the visitor identifier when you need it.
fpPromise.then(fp => fp.get()).then(result => {
// This is the visitor identifier:
const visitorId = result.visitorId
console.log('唯一标识:' + visitorId)
})
</script>