Nuxt/examples/dynamic-layouts/middleware/mobile.js

5 lines
157 B
JavaScript
Raw Normal View History

2017-03-17 17:03:12 +00:00
export default function (ctx) {
let userAgent = ctx.req ? ctx.req.headers['user-agent'] : navigator.userAgent
ctx.isMobile = /mobile/i.test(userAgent)
}