在NUXT中间件中识别用户设备的最佳方法是什么
您好,
我将使用 nuxtjs 开发一个 Web 应用程序。由于某些原因,我需要在中间件中识别用户的设备。我知道如何在请求上下文中获取用户代理,但很难手动区分所有设备。我还找到了 Nuxt/Device 模块,但无法在中间件中处理它。 我在我的中间件文件中尝试此代码:
import device from '@nuxtjs/device'
export default (context) => {
console.log(device)
}
buy 我只在控制台中获取模块详细信息。请分享您的经验来帮助我。
Greeting,
I'm going to develop a web application using nuxtjs. For some reasons I need to recognize users' devices in the middleware. I know how to get user agent in req context, but it is hard to distinguish all devices manually. I also found Nuxt/Device module but couldn't handle it in the middleware.
I try this code in my middleware file:
import device from '@nuxtjs/device'
export default (context) => {
console.log(device)
}
buy I only get module details in my console. Please share your experience to help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于中间件中使用NUXT/设备,我们必须在上下文中运行它。应用类似:
for using Nuxt/Device in middleware we had to run it in the context.app like: