LoginSignup
1
0

definePropsの戻り値は捨ててもよかった

Posted at

コンポーネントのプロパティとエミットですが、

sample.vue
<template>
    <div @click="$emit('click')">{{ message }}</div>
</template>

<script setup>
const props = defineProps([
    "message"
]);
const emit = defineEmits([
    "click"
]);
</script>

templateの中だけで完結して、script内で参照しない場合は・・・

sample.vue
<template>
    <div @click="$emit('click')">{{ message }}</div>
</template>

<script setup>
defineProps([
    "message"
]);
defineEmits([
    "click"
]);
</script>

戻り値を捨てても問題ないんですね。
ずっとeslintに「propsは使ってない変数だよ!」怒られてたんですが、ようやく解放されました。

1
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
1
0