如何从组件A上触发组件B上的V-show



我在单击另一个组件时试图显示一个组件。

我尝试使用道具,但它没有用,我可能做错了。

嘿,所以这取决于组件所在的位置,但通常将按钮放在通常称为子组件的"内部"组件上(因为它放置在"内部"的内部。父母"组件(在这种情况下,您需要向上发射,然后对父母的事件做出反应,看起来像这样:

//Parent
<template>
   <childWithButton @buttonClick="doSomething"/>
</template>
.
.
.
methods: {
   doSomething(){
     ....<
}
}
...
//child ("childWithButton")
<template>
  <button @click="$emit('buttonClick')></button>
</template>

最新更新