<span ref="projectButton"> <el-popover v-model="visible" trigger="manual" placement="bottom" @show="show" @hide="hide"> <p>啦啦啦</p> <el-button slot="reference" type="primary" @click="visible = !visible">show</el-button> </el-popover> </span> data () { return { visible: false } }, methods: { show () { document.addEventListener(‘click‘, this.hidePanel, false) }, hide () { document.removeEventListener(‘click‘, this.hidePanel, false) }, hidePanel (e) { if (!this.$refs.projectButton.contains(e.target)) { this.visible = false this.hide() } } }
原文:https://www.cnblogs.com/cs122/p/13042283.html