import { isMobile } from 'mobile-device-detect'
export default {
layout(context) {
const mobile = isMobile ? 'mobile-layout' : 'desktop-layout
return mobile
}
}
I am creating a nuxt app. i am trying to detect when the view is either mobile or desktop. if i make a change to the code in my ide and save then isMobile is true and and it will get set to mobile-layout. However once you refresh the page isMobile is false and it will get set to desktop-mobile.
Im assuming that the layout is being set before it has time to determine if isMobile is true or false and automatically being set too false.
I cant figure out how to make something like this work. No matter what i try it always fails.