我使用的是角SSR,我希望获得签名浏览器或macAddress来指定用户浏览器,当我使用@fingerprintjs/fingerprintjs包并构建我的项目ssr和服务器ssr时,没有载入web {head和body空标签}的页面
<html>
<head></head>
<body></body>
</html>发布于 2022-02-15 12:13:47
我试过了,它在FingerprintJS npm软件包上运行得很好。
另外,对于某些配置,您可能会遇到不可用的document.location API的错误。因此,我建议在客户端使用isPlatformBrowser函数显式地呈现它。
import { Component } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Inject } from '@angular/core';
import { PLATFORM_ID } from '@angular/core';
import FingerprintJS from '@fingerprintjs/fingerprintjs'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title: string = 'fpjs-angular';
constructor(@Inject(PLATFORM_ID) platformId: Object) {
if (isPlatformBrowser(platformId)) {
const fpPromise = FingerprintJS.load()
; (async () => {
// Get the visitor identifier when you need it.
const fp = await fpPromise
const result = await fp.get()
console.log(result.visitorId)
})()
}
}
}https://stackoverflow.com/questions/68976529
复制相似问题