大版面建立

建立 layout/default

<template>
  <Html lang="zh-Hant-TW">
    <Body class="wrapper">
      <div class="layout">
        <the-header/> <!-- app/components/TheHeader.vue -->
        <slot /> 
        <the-footer/> <!-- app/components/TheFooter.vue -->
      </div>
    </Body>
  </Html>
</template>

<!-- setup = composition  API 寫法 -->
<script setup lang="ts">
  const runtimeConfig = useRuntimeConfig();
  // 提取共用變數與計算屬性
  // runtimeConfig 會在 nuxt.config.ts 設定
  const baseUrl = runtimeConfig.public.baseUrl;

  useHead({
    link: [
      // 網頁頁籤 icon
      { rel: 'shortcut icon', type: 'image/x-icon', href: `${baseUrl}/favicon.ico` },
      // Google Fonts
      { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
      { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: '' },
      { 
        rel: 'preload', 
        as: 'style', 
        href: 'https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap' 
      },
      { 
        rel: 'stylesheet', 
        href: 'https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap',
        media: 'print',
        onload: "this.media='all'"
      },
      // 繼續增加其他 link
    ],
  });
</script>

有使用多國語言套件 @nuxtjs/i18narrow-up-right

Last updated

Was this helpful?