Nuxt3ã§<component :is>
ã使ãã¨ã
ã³ã³ãã¼ãã³ããè¦ç´ ãåçã«è¨å®ã§ããããã
propsã«to
ãããã¨ãã¯ã<NuxtLink>
ã«ãã¦ã
ãã以å¤ã¯<div>
ã«ããããªã¨æã£ãã¨ãã®åå¿é²(*´Ïï½*)
<template> <component :is="component" :to="to"> <slot></slot> </component> </template> <script setup lang="ts"> const props = defineProps<{ to?: string; }>(); const component = computed(() => { // NuxtLinkã¯åçã«importããããããresolveComponentã§åå¾ãã if (props.to) return resolveComponent('NuxtLink'); return 'div'; }); </script>
以ä¸!! ããã§ã³ã³ãã¼ãã³ãã¥ãããæã...(*´Ïï½*)