在我的Nuxt项目中,我使用了fingerprintjs模块,我是一个前端框架的新手。
我可以在控制台中获取用户指纹代码,但不能使用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?
发布于 2021-06-10 22:15:51
这段代码你在哪里?
如果它在Nuxt插件(例如/plugins/my-plugin.js)中,那么您可以使用以下代码
export default ({ store }) => {
// your code
}如下所示:https://nuxtjs.org/docs/2.x/concepts/context-helpers
如果您位于.vue文件中通常script部分,那么这就足够了
if (this.$store.state.auth.loggedIn) {
// your code
}https://stackoverflow.com/questions/67919993
复制相似问题