安装组件:
npm i @fingerprintjs/fingerprintjs -S
# or
yarn add @fingerprintjs/fingerprintjs -S
创建一个async的methord:
async asyncCall() {
// We recommend to call `load` at application startup.
const fp = await FingerprintJS.load()
// The FingerprintJS agent is ready.
// Get a visitor identifier when you'd like to.
const result = await fp.get()
// This is the visitor identifier:
const visitorId = result.visitorId
console.log(visitorId)
return visitorId
}
在业务代码中使用:
this.asyncCall().then(res => {
const terminalId = res
that.$api
.Login({
employeeNumber: that.formLogin.employeeNumber,
password: that.formLogin.password,
terminalId: terminalId,
terminalType: that.formLogin.terminalType
})
.then(() => {
// 登录成功后的操作
})
})