通过按Enter将事件附加到“ v-btn”

时间:2019-11-26 02:13:31

标签: javascript vue.js vuetify.js

除按Enter键外,所有其他操作均需要帮助。 我有формувv-checkbox

   <v-expansion-panel>
    <v-expansion-panel-header disable-icon-rotate @click="editingTarget" class="headerHeight">
        <span class="title"> {{description.targets}}</span>
        <template v-slot:actions>
            <v-btn fab small>
                <v-icon v-if="isEditing.target">mdi-close</v-icon>
                <v-icon v-else>mdi-pencil</v-icon>
            </v-btn>
        </template>
    </v-expansion-panel-header>
    <p class="subtitle-1  px-6" style="opacity: 0.9" v-if="(profileDetails) && (!isEditing.target)">
        {{profileDetails.target}}</p>
    <v-expansion-panel-content
    >
        <v-row>
            <v-col xs="12"
                   md="6"
                   lg="6"
                   v-for="(item, i) in valueCheckBox"
                   :key="i"
                   class="colCheckBox"
            >
                <div style="width: 250px">
                    <v-checkbox v-model="checkBox" :value="item.value">
                        <template v-slot:label>
                            <div class="check-box-custom">
                                <span class="font-weight-regular">{{item.value}}</span>
                            </div>
                        </template>
                    </v-checkbox>
                </div>
            </v-col>
        </v-row>
        <v-card-actions>
            <div class="flex-grow-1"></div>
                <v-btn
                        color="blue lighten-1"
                        @click="$emit('close-panel', []); save()"
                >
                    Save
                </v-btn>
        </v-card-actions>
    </v-expansion-panel-content>
   </v-expansion-panel>

如果我在成功的表单上输入了任何信息,但没有表单,则我没有“输入”,“表单”

        methods: {
        ...mapActions(['editAbout']),

        save() {
            this.isEditing.target = false

            const target = this.checkBox.join(", ")
            if (target !== profileDetails.target) {

                const obj = {
                    name: 'target',
                    profileDet: {
                        id: profileDetails.id,
                        target: target
                    }
                }
                this.editAbout(obj)
            }
        },

什么才没有尝试?我认为一切,但不知何故 我只是无法将事件附加到Enter键 求助!!

1 个答案:

答案 0 :(得分:0)

尝试在相应的标签(即@keydown.enter.native.stop.prevent="event")中使用v-text-field道具,以在释放Enter键时触发event()

在您的情况下,像这样:

<v-checkbox @keydown.enter.native.stop.prevent="$emit('close-panel', []); save()" v-model="checkBox" :value="item.value">