screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue 3 Detect Mobile</h3> <p v-if="isMobile">This is a mobile device</p> <p v-else>This is not a mobile device</p> </div> <script type="module"> const { createApp, ref,onMounted } = Vue; createApp({ setup() { const isMobile = ref(false); const detectMobile = () => { isMobile.value = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); }; onMounted(() => { detectMobile(); }); return { isMobile, }; } }).mount("#app"); </script> <style scoped></style> </body> </html>