假设子组件里有这么一个方法
methods:{ showDiv(){ this.release = true; } }
在父组件引用子组件时绑定
<unio2o-release-message-alert ref="unio2oReleaseMessageAlert" ></unio2o-release-message-alert> <script> import unio2oReleaseMessageAlert from '@/components/module/coupon/releaseMessageAlert.vue'; export default { components:{ unio2oReleaseMessageAlert } <script>
在父组件中假如需要触发子组件中的方法,举例(代码举一反三):
btnClick(){ //点击悬浮 this.$refs.unio2oReleaseMessageAlert.showDiv(); },