我無法弄清楚如何在一個組件引發兄弟方法觸發兄弟方法VUE JS
我有一個方法,像這樣的
methods: {
closeModal: function(){
function closeM(){
$('.modal').css({opacity: 0 , 'visibility':'hidden'});
}
closeM();
},
closeOutside: function(){
$(document).mouseup(function (e){
var container1 = $('.modal__box');
if (!container1.is(e.target) &&
container1.has(e.target).length === 0)
{
this.$emit('closeModal',closeM());
}
});
}
}
我的模板
<div class="modal" @click="closeOutside()">
<div class="modal__box z-depth-2 pr">
<div class="modal__header"> {{header}} </div>
<i class="modal__close pa fa fa-times" @click="closeModal() "> </i>
<div class="modal__content">
<slot> </slot>
</div>
</div>
</div>
我無法觸發closeModal,我錯過了什麼?即時通訊有點新vue js,爲什麼它不工作?謝謝!
取代你的意思是,你不能調用從''closeOutside' closeModal'? – Bert
是的,我想觸發closeModal的功能 – clarkoy