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?

More than 5 years have passed since last update.

【Nuxt.js】変数を他のコンポーネントへ受け渡す/ 他のコンポーネントから変数を受け取る

Posted at
export defaultに受け渡したい変数を記載
index.vue
<script>
export default {
  data() {
    return {
      // 省略
    }
  },
  send_data: send_data  // 他のコンポーネントに渡したい値
}
</script>
importで受け取りたい変数を受け取る
他のコンポーネント.vue
<template>
  <p>{{ send_data }}</p>
</template>

<script>
import send_data from "~/pages/index.vue"

export default {
  data() {
    return {
      send_data: send_data.send_data
    }
  },
  // 省略
</script>
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?