Nuxt.js 変数を使用するサンプル

環境
node v20.13.1
npm 10.8.0
Nuxt.js v3.11.2

概要
マスタッシュ構文である「{{}}」と、setupを使用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<script setup lang="ts">
const msg1 = ref<string>("Study Skik!!");
const msg2 = ref<string>("information 123!");
</script>
<template>
<div>
<h1>{{ msg1 }}</h1>
<h1>{{ msg1 }}</h1>
<h2>{{ msg2 }}</h2>
</div>
</template>
<script setup lang="ts"> const msg1 = ref<string>("Study Skik!!"); const msg2 = ref<string>("information 123!"); </script> <template> <div> <h1>{{ msg1 }}</h1> <h1>{{ msg1 }}</h1> <h2>{{ msg2 }}</h2> </div> </template>
<script setup lang="ts">

const msg1 = ref<string>("Study Skik!!");
const msg2 = ref<string>("information 123!");

</script>

<template>
  <div>
    <h1>{{ msg1 }}</h1>
    <h1>{{ msg1 }}</h1>
    <h2>{{ msg2 }}</h2>
  </div>
</template>

 

IT

Posted by arkgame