0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Nuxt 3 / Vue 3 - 外部 jabascript ファイル ( src ) を設定する例

Posted at

問題

template に script タグが書けない

<template>
  <html>
    <head>
      <script src="example.js"></script>
    </head>
  </html>
</template>

以下エラーが発生する

Tags with side effect (<script> and <style>) are ignored in client component templates.

対策

useHead を使えば良い

<script setup lang="ts">
useHead({
  script: [
    {
      src: 'example.js',
      tagPriority: 1,
    },
  ],
})
</script>

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

プロフィール・経歴

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?