【问题标题】:Tooltip on a modal模态框上的工具提示
【发布时间】:2025-12-06 11:45:01
【问题描述】:

谁能帮我解决我的问题, 我有一个模式需要在“打开对话框”按钮上提供工具提示,

这是来自 vuetify 的示例: https://codepen.io/czechsebastian/pen/mdyyWze?&editable=true&editors=101

当我使用 vuetify 工具提示悬停按钮时,我想显示一个文本。

非常感谢

<div id="app">
  <v-app id="inspire">
    <v-row justify="center">
      <v-dialog v-model="dialog" persistent max-width="290">
        <template v-slot:activator="{ on }">
          <v-btn color="primary" dark v-on="on">Open Dialog</v-btn>
        </template>
        <v-card>
          <v-card-title class="headline">Use Google's location service?</v-card-title>
          <v-card-text>Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.</v-card-text>
          <v-card-actions>
            <v-spacer></v-spacer>
            <v-btn color="green darken-1" text @click="dialog = false">Disagree</v-btn>
            <v-btn color="green darken-1" text @click="dialog = false">Agree</v-btn>
          </v-card-actions>
        </v-card>
      </v-dialog>
    </v-row>
  </v-app>
</div>

【问题讨论】:

标签: javascript vue.js vuetify.js


【解决方案1】:

您可以将按钮移到模态组件之外并更改激活器。

<div id="app">
  <v-app id="inspire">
    <v-row justify="center">
      <v-tooltip bottom>
        <template v-slot:activator="{ on }">
          <v-btn color="primary" dark  v-on="on" @click="dialog = !dialog">Open Dialog</v-btn>
         </template>
        <span>Tooltip</span>
       </v-tooltip>
      <v-dialog v-model="dialog" persistent max-width="290">
        <v-card>
          <v-card-title class="headline">Use Google's location service?</v-card-title>
          <v-card-text>Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.</v-card-text>
          <v-card-actions>
            <v-spacer></v-spacer>
            <v-btn color="green darken-1" text @click="dialog = false">Disagree</v-btn>
            <v-btn color="green darken-1" text @click="dialog = false">Agree</v-btn>
          </v-card-actions>
        </v-card>
      </v-dialog>
    </v-row>
  </v-app>
</div>

【讨论】: