【发布时间】:2017-09-26 23:45:10
【问题描述】:
我正在 Vue.js 中构建一个应用程序,其一般结构如下:
<app>
<filters-component></filters-component>
<div class="off-canvas-content">
<nav-component></nav-component>
<div class="row card-grid">
<card-component v-for="item in items">
<modal-component v-if="launchModal === true"></modal-component>
</card-component>
</div>
</div>
</app>
只有当 launchModal 的数据元素设置为 true 时(单击按钮启动模式后),这才允许我在 DOM 上呈现模式。这很好用,但是当它关闭时我需要做相反的事情。
根据 Foundation 的文档,Reveal(模态)组件在关闭时应该发出一个名为 closed.zf.reveal 的事件。
如何在父元素(卡片组件)上侦听此事件,然后在调用时将 launchModal 更改为 false?
谢谢!
【问题讨论】:
-
你能显示
modal-component的Vue代码吗? -
这是两个组件的要点。我确定我在这方面做错了很多,这是我第一次在大型应用程序上使用 Vue,请温柔一点。哈哈!我知道很多 JS 都可以重构,我只是想让一切都先正常工作;)gist.github.com/DinsmoreDesign/64d2e45119e842838507c192283ff8c8 仅供参考:正在传递的数据来自父应用程序上的 API 调用,并通过道具传递。
-
那是卡片,组件,我们能看到模态组件吗?
-
它就在那里,你需要向下滚动一点;)
-
德普。我看到了。我想这将是
this.$el然后在我的回答中。
标签: javascript vue.js zurb-foundation vuejs2 vue-component