Vuetify 如何在数据表中打开和关闭对话框

Gre*_*ing 7 javascript dialog vue.js vuetify.js

我们为一家人员配备公司构建了一个应用程序,管理员可以在其中查看 Vuetify 数据表中的用户。在那个表中,我们想显示用户注释,但它们有时很长并且不适合表格单元格。我们只想单击一个按钮并在对话框中打开注释。

问题是,如果我们有 200 个用户,并且我们单击按钮打开“dialogNotes”,每个用户对话框都会打开。我们如何调整我们的代码,以便只打开该用户的对话框?

<template slot="items" slot-scope="props">
                <td>
                <v-checkbox
                  primary
                  hide-details
                  v-model="props.selected"
                ></v-checkbox>
              </td>
                <td>{{props.item.status}}</td>
                <td>
          <img v-if="props.item.photoUrl" :src="props.item.photoUrl" class="user-img">
          <img v-if="!props.item.photoUrl" src="/static/avatar.png" class="user-img">
        </td>
                <td>
                <router-link v-if="props.item.name" v-bind:to="'/staff/' + props.item.id">{{ props.item.name }}</router-link>
        <router-link v-if="!props.item.name" v-bind:to="'/staff/' + props.item.id">{{ props.item.id }}</router-link>
                </td>
                <td>
                <v-btn icon color="primary" small @click.stop="dialogNote = true"><v-icon small>open_in_new</v-icon></v-btn>
                    <v-dialog v-model="dialogNote" scrollable lazy max-width="500" :key="props.item.id">
                    <v-card>
                      <v-card-title>
                        <span>{{ props.item.name }} Note</span>
                      </v-card-title>
                      <v-card-text>
                        {{props.item.note}}
                      </v-card-text>
                      <v-card-actions>
                        <v-btn color="primary" flat @click.stop="dialogNote=false">Close</v-btn>
                      </v-card-actions>
                    </v-card>
                  </v-dialog>
                </td>
                <td>{{props.item.greek}}</td>
                <td>
                <span v-if="props.item.tipsUrl">Yes</span>
              </td>
                <td>{{props.item.waiver}}</td>
                <td>{{props.item.media}}</td>
              <td>{{ props.item.howHear }}</td>
            </template>
Run Code Online (Sandbox Code Playgroud)

数据:

dialogNote: false,
Run Code Online (Sandbox Code Playgroud)

acd*_*ior 7

dialogNote成一个对象,并使用dialogNote[props.item.id]告诉如果该项目是开放与否。

在 中声明它data,例如:

dialogNote: {},
Run Code Online (Sandbox Code Playgroud)

并像这样使用它:

 <v-dialog v-model="dialogNote[props.item.id]" scrollable lazy max-width="500" :key="props.item.id">
Run Code Online (Sandbox Code Playgroud)

并更改打开/关闭按钮。


您的模板: