index.vue
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<template>
<PageWrapper title="点内外部触发事件">
<ClickOutSide @clickOutside="handleClickOutside" class="flex justify-center">
<div @click="innerClick" class="demo-box">
{{ text }}
</div>
</ClickOutSide>
</PageWrapper>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { ClickOutSide } from '/@/components/ClickOutSide';
import { PageWrapper } from '/@/components/Page';
export default defineComponent({
components: { ClickOutSide, PageWrapper },
setup() {
const text = ref('Click');
function handleClickOutside() {
text.value = 'Click Out Side';
}
function innerClick() {
text.value = 'Click Inner';
}
return { innerClick, handleClickOutside, text };
},
});
</script>
<style lang="less" scoped>
.demo-box {
display: flex;
width: 100%;
height: 300px;
font-size: 24px;
color: #fff;
background-color: #408ede;
border-radius: 10px;
justify-content: center;
align-items: center;
}
</style>