直接上代码: mounted: function () { let that = this; $(document).on('click', function (e) { let dom = $('.myDiv')[0]; // 自定义div的class if (dom) { // 如果点击的区域不在自定义dom范围 if (!dom.contains((e.target))) { that.showMyDiv = false; } } }); }, beforeDestroy() { $(do…