vue-mobile-detection
Vue.js prototype function this.$isMobile()
that returns a Boolean value depending on whether or not the user is browsing with a mobile
Demo
https://ajerez.github.io/vue-mobile-detection/
Installation
With npm (Recommended)
npm install vue-mobile-detection
yarn
yarn add vue-mobile-detection
Usage
Plugin installation
import VueMobileDetection from "vue-mobile-detection";
Vue.use(VueMobileDetection);
/* After the install you can use this.$isMobile() in all your vue components */
Using the plugin
<template>
<div id="app">
<!-- Use in template -->
<div v-if="$isMobile()">MOBILE</div>
<div v-else>DESKTOP OR TABLET</div>
</div>
</template>
<script>
export default {
created() {
// Use in js
console.log(this.$isMobile());
}
};
</script>
License
This project is licensed under the terms of the MIT license