vue3-mobile-detection

Mobile browser detection for Vue.js 3
26,319 2
Install
npm install vue3-mobile-detection
Latest Version:1.0.5
Vue:3
License:MIT
Last Updated:Nov 13, 2021
Links: GitHub  ·  npm
Maintainer: kanhar

This package adds mobile detection in vue.js 3 projects.

Installation:

npm i vue3-mobile-detection

<OR>

yarn add vue3-mobile-detection

Composition API - recommended

// MyComponent.vue
<template>
  <div id="app">
    <!-- Use in template -->
    <div v-if="$isMobile()">MOBILE</div>
    <div v-else>DESKTOP OR TABLET</div>
  </div>
</template>

<script>
import { useMobileDetection } from "vue3-mobile-detection";

export default defineComponent({
  setup() {
    const { isMobile } = useMobileDetection();
    return { isMobile };
  }
});
</script>

Legacy - usage as plugin

Usage - plugin installation:

import Vue3MobileDetection from "vue3-mobile-detection";
import { createApp } from "vue";

let app = createApp(App);
app.use(Vue3MobileDetection);

Usage - in component:

<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>

Related Packages

vue-mobile-detection

Vue.js prototype function `this.$isMobile()` that returns a Boolean value depend...

139,558 69
tdesign-mobile-vue

tdesign-mobile-vue

1,024,396 437
heren-mobile-vue

heren-mobile-vue

1,031 437
vue-mm-component

**技术栈** vue + vuex + vue-router + axios + vant

779 1

Version History

Version Released License
1.0.5 MIT
1.0.4 MIT
1.0.3 MIT
1.0.2 MIT
1.0.1 MIT