I am developing an SPA using Vue 2.0. The components developed so far are for the "desktop" browsers, for example, I have
Main.vue, ProductList.vue, ProductDetail.vue,
I want another set of components for the mobile browsers, such as MainMobile.vue, ProductListMobile.vue, ProductDetailMobile.vue,
My question is, where and how do I make my SPA render the mobile version of components when viewing in a mobile browser?
Please note that I explicitly want to avoid making my components responsive. I want to keep two separate versions of them.
Thanks,
I had this same problem, I solved it using a neutral and no layout vue file (Init.vue) that will be accessed by mobile and desktop, and this file redirects to the correct file.
Let's suppose that I have the Main.vue and the MainMobile.vue. I will add an Init.vue that will redirect. So my router/index.js is that:
At the Init.vue file, the mobile/desktop detection will happen:
The isMobile() function used is very simple, you can change to any other.
A bit late for this but, in case if any of you are looking to bind watchers for the viewport size, and/or check whenever the page loads. Its a lot of boilerplate to write but can be useful for small applications.