我有一个VueJS组件。如果有“事件”事件的处理程序,我需要显示其中的某些部分。
<!-- here is my simple component -->
<cmp v-on:event='foo'></cmp>
<!-- here its template -->
<div id='cmpTemplate'>
<p>Show it only if v-on:event is not empty</p>
<div>
添加附加属性不是那么简单的解决方案。
我希望将事件从子组件发送到其父组件,该父组件应更改视图。
我能够创建事件并发出它,但是我的模板似乎没有注册它,我使用的是单一文件组件(证监会)。另外,如果我手动更新数据对象,所有工作都很好。
App.vue (父母)
<template>
<div v-on:change-view="updateView">
<!-- render the currently active component/page here -->
<component v-bind:is="currentView&
我不明白为什么我的活动没有被正确收听。在这里,正如您所看到的,我已经创建了一个带有基于@click按钮事件的emit事件的组件。然后,我创建了我的"v-on: my -event“来捕获它。我不明白为什么我在控制台中看不到"yolo”。 //Call of the component BaseButton
<base-button variant="projeo-btn-deeppurple" event-type="yololol">
<span class="mr-2">+</span>