imps-platform-detect
v1.0.9
Published
A vue js plugin, which can detect device for vue2 and vue3
Downloads
8
Maintainers
Readme
Imps Platform Detect
You can easily detect a device by using this plugin. This plugin is really lightweight and easy to use.
Documentation
see documentation here
installation
Vue2
npm i imps-platform-detect --tag=v2
Vue3
npm i imps-platform-detect --tag=v3
Usage
#Vue 2
// import and use in your main.js file
import Vue from 'vue'
import App from './App.vue'
import ImpsPlatform from 'imps-platform-detect';
Vue.use(ImpsPlatform);
new Vue({
render: h => h(App),
}).$mount('#app')
// use on vue components
<template>
<div>
<div v-if="$platform.isMobile">Platform is Mobile</div>
<div v-if="$platform.isWeb">Platform is Web</div>
<div v-if="$platform.isTablet">Platform is Tablet</div>
</div>
</template>
// use on vue script
<script>
export default {
mounted(){
console.log(`Platform is ${this.$platform.isMobile}`);
console.log(`Platform is ${this.$platform.isWeb}`);
console.log(`Platform is ${this.$platform.isTablet}`);
}
}
</script>
#Vue 3
// import and use in your main.js file
import { createApp } from 'vue';
import App from './App.vue';
import ImpsPlatform from 'imps-platform-detect';
const app = createApp(App);
// Install the plugin globally
app.use(ImpsPlatform);
app.mount('#app');
// use on vue components
<template>
<div>
<div v-if="$platform.isMobile">Platform is Mobile</div>
<div v-if="$platform.isWeb">Platform is Web</div>
<div v-if="$platform.isTablet">Platform is Tablet</div>
</div>
</template>