Blame view

src/views/demo/feat/click-out-side/index.vue 1.05 KB
陈文彬 authored
1
<template>
2
  <PageWrapper title="点内外部触发事件">
vben authored
3
    <ClickOutSide @click-outside="handleClickOutside" class="flex justify-center">
4
      <div @click="innerClick" class="demo-box">
陈文彬 authored
5
6
7
        {{ text }}
      </div>
    </ClickOutSide>
8
  </PageWrapper>
陈文彬 authored
9
10
11
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
vben authored
12
  import { ClickOutSide } from '/@/components/ClickOutSide';
13
14
  import { PageWrapper } from '/@/components/Page';
陈文彬 authored
15
  export default defineComponent({
16
    components: { ClickOutSide, PageWrapper },
陈文彬 authored
17
18
19
20
21
22
23
24
25
26
27
28
29
    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

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