Blame view

src/views/demo/comp/click-out-side/index.vue 1.08 KB
陈文彬 authored
1
<template>
2
  <div class="px-10">
陈文彬 authored
3
4
    <Alert message="点内外部触发事件" show-icon class="mt-4"></Alert>
    <ClickOutSide @clickOutside="handleClickOutside" class="flex justify-center mt-10">
5
      <div @click="innerClick" class="demo-box">
陈文彬 authored
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
        {{ text }}
      </div>
    </ClickOutSide>
  </div>
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { Alert } from 'ant-design-vue';
  import ClickOutSide from '/@/components/ClickOutSide/index.vue';
  export default defineComponent({
    components: { ClickOutSide, Alert },
    setup() {
      const text = ref('Click');
      function handleClickOutside() {
        text.value = 'Click Out Side';
      }

      function innerClick() {
        text.value = 'Click Inner';
      }
      return { innerClick, handleClickOutside, text };
    },
  });
</script>
30
31
32
33
34
35
36
37
38
39
40
41
42
43

<style lang="less" scoped>
  .demo-box {
    display: flex;
    width: 100%;
    height: 300px;
    font-size: 24px;
    color: #fff;
    background: #408ede;
    border-radius: 10px;
    justify-content: center;
    align-items: center;
  }
</style>