LoginSignup
1
1

More than 3 years have passed since last update.

[Vue.js] vue-property-decoratorで関数型コンポーネントを利用する

Last updated at Posted at 2019-12-16

vue-property-decoratorで関数型コンポーネントを利用する方法

やることは2つ
- templateタグにfunctionalを設定する
- class内でfunctional = trueを定義する
templateタグにfunctionalを設定するだけで大丈夫っぽい

実際に書いてみると以下みたいな感じ

<template functional>
  <div>
    {{ props.text }}
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator'

@Component
export default class Child extends Vue {
  // trueを設定する
  functional = true

  @Prop({ default: "", type: String }) text: string
}
</script>
1
1
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
1
1