# 发现一个ElementUI中隐藏的巨好用的指令

* 抖音：<https://v.douyin.com/SYA1qMX/>
* B站：<https://www.bilibili.com/video/BV1K54y1u7s9/>

> **demo预览：**
>
> <https://sunzsh.github.io/vue-demos/#/clickoutside>
>
> **代码：**
>
> <https://github.com/sunzsh/vue-el-demo/blob/master/src/views/clickoutside.vue>

我在饿了么UI的源码里啊

发现一个隐藏的指令特别好用

就这个颗粒clickoutside

顾名思义呢

就是它可以监听到某个元素以外的

区域被点击

那使用起来也很简单啊

先把它导进来

然后呢注册成指令就可以用了

像这样v-clickoutside指定到一个方法

效果呢就是这样 大家看

我点击这个元素内部没有什么反应

然后点击这个元素以外的区域 大家看

只要这个网页的任何区域

他都会被触发


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sunzsh.gitbook.io/xiaoshan.bug/fa-xian-yi-ge-elementui-zhong-yin-cang-de-ju-hao-yong-de-zhi-ling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
