Vue中點擊組件外關閉組件的實現方式

Vue定義全局點擊函數,參數爲點擊的回調函數。 Vue.prototype.globalClick = function (callback) { //頁面全局點擊 $(document).click(callback); } 組件掛載後監聽全局的點擊事件 mounted:function () { this.globalClick(this.handleClickOut); }, 隱藏
相關文章
相關標籤/搜索