LoginSignup
0
0

[Vuetify3]ボタンにtooltipもdialogも両方とも設定したい時

Last updated at Posted at 2024-03-28
package.json
{
  "dependencies": {
    "vue": "^3.4.15",
    "vuetify": "^3.5.9"
  }
}

dialogのactivatorもtooltipのactivatorも、どちらも同じコンポーネントのv-bindとして渡したい......という状況の解決方法。
こんな感じにしたら動いたっす。

HogeComponentParent.vue
<v-dialog>
  <template #activator="{ props: dialogActivator }">
    <v-tooltip text="hello, tooltip">
      <template #activator="{ props: tooltipActivator }">
        <HogeComponent
            // mergePropsを使って二つのpropsを合成するのがポイント
          v-bind="mergeProps(tooltipActivator, dialogActivator)"
        />
      </template>
    </v-tooltip>
  </template>
  <template #default>
    <v-sheet class="pa-4">
      <p>hello, dialog</p>
    </v-sheet>
  </template>
</v-dialog>

参考

mergeProps()
https://ja.vuejs.org/api/render-function#mergeprops

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