【问题标题】:How to cacth 'hidden.bs.modal' in vuejs?如何在 vue js 中捕获“hidden.bs.modal”?
【发布时间】:2018-12-26 00:42:01
【问题描述】:

我想处理事件hidden.bs.modal 来清除变量中的数据。

但它似乎不再工作了。

<template>
    <div id="my_modal"
         class="modal"
         tabindex="-1"
         role="dialog"
         aria-hidden="true"
         ref="my_modal">
        ...
    </div>
</template>

<script>
    export default {
        mounted() {
            $(this.$refs.my_modal).on('hidden.bs.modal', this.doSomething());
        },

        methods: {
            doSomething() {
                // Do something
            },
        },
    }
</script>

【问题讨论】:

    标签: vue.js bootstrap-4 bootstrap-modal laravel-5.6


    【解决方案1】:

    doSomething 之后不需要括号。你想传递函数本身,而不是它的结果

     mounted() {
         $(this.$refs.my_modal).on('hidden.bs.modal', this.doSomething);
     },
    

    【讨论】:

    猜你喜欢
    • 2018-12-28
    • 1970-01-01
    • 2023-02-03
    • 2018-07-29
    • 1970-01-01
    • 2017-10-15
    • 2020-06-21
    • 1970-01-01
    • 2021-05-04
    相关资源
    最近更新 更多