Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Load Component Dynamically

To load component based on user device, you can use isDesktop or isMobile from stores/clientType

import useClientTypeStore from "~/stores/clientType";
import { storeToRefs } from "pinia";

const clientTypeStore = useClientTypeStore();
const { isDesktop, isMobile } = storeToRefs(clientTypeStore);
const myButton = defineAsyncComponent(() =>
  import("./components/MyButton.vue")
);

then can use in <template>

<template>
  <div>
    <template v-if="isDesktop">
      <component :is="myButton"></component>
    </template>
  </div>
</template>