【问题标题】:How attributes like ` v-b-modal` and `v-b-toggle` works? Where are they listened?`v-b-modal` 和 `v-b-toggle` 等属性如何工作?他们在哪里听?
【发布时间】:2019-10-06 15:01:01
【问题描述】:

我想添加一个像这两个这样的自定义属性并触发其他事件。但我不知道它们是如何工作的。

例如:

<b-button v-b-modal.modal-1>Launch demo modal</b-button>

// Generated html5 tag
<button type="button" class="btn btn-secondary">Launch demo modal</button>

生成的 html5 目标上没有使用额外的属性以供参考,也没有显式注册事件侦听器。

幕后发生了什么? v-b-modal 是如何使用的?

【问题讨论】:

标签: vue.js bootstrap-vue


【解决方案1】:

查看https://github.com/bootstrap-vue/bootstrap-vue/blob/dev/src/directives/modal/modal.js 的源代码,了解它们是如何实现的。它们在 $root 上发出事件,模态监听。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    • 2018-08-13
    • 2021-03-13
    • 2011-03-24
    • 1970-01-01
    • 2019-05-04
    • 2022-10-23
    相关资源
    最近更新 更多