问题描述
我在 Nuxt 项目中使用了指纹模块,我是前端框架的新手。
我可以在控制台中获取用户指纹代码,但我无法使用 VuexStore 实例。
if (process.browser) {
const fpPromise = FingerprintJS.load();
(async () => {
// Get the visitor identifier when you need it.
const fp = await fpPromise
const result = await fp.get()
// This is the visitor identifier:
const visitorId = result.visitorId
console.log(visitorId)
})()
}
如何在visitorId的实例中使用vuexStore?
解决方法
你在哪里有这个代码?
如果它在 Nuxt 插件中(例如 /plugins/my-plugin.js
),那么你可以使用它
export default ({ store }) => {
// your code
}
如下所示:https://nuxtjs.org/docs/2.x/concepts/context-helpers
如果您在 script
文件中的常规 .vue
部分,那么这应该足够了
if (this.$store.state.auth.loggedIn) {
// your code
}