【发布时间】:2020-06-04 22:43:52
【问题描述】:
我有父组件和子组件...当我单击父组件中的按钮时,我需要运行子方法。 示例代码:
父母
<template>
<child-component></child-component>
<button>Open Modal in child Component (set modal = true in child component)</button>
</template>
孩子:
<template>
<div v-if="modal">
<button @click="modal = false">Close</button>
</div>
</template>
<script>
export default {
data() {
return {
modal: false
}
}
}
</script>
【问题讨论】:
-
这里可以找到类似问题的解决方案:stackoverflow.com/a/45463576/4267716
标签: vue.js