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

How to trigger v-show on Component B from Component A

我试图在单击另一个组件上的按钮时显示一个组件。

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

嘿,这取决于组件的位置,但通常按钮会在 "internal" 组件上,通常称为子组件(因为它位于 "parent"组件)在这种情况下你需要向上发出然后对父级中的事件做出反应,看起来像这样:

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