|
1
|
<template>
|
vben
authored
|
2
|
<PageWrapper title="点内外部触发事件">
|
vben
authored
|
3
|
<ClickOutSide @click-outside="handleClickOutside" class="flex justify-center">
|
nebv
authored
|
4
|
<div @click="innerClick" class="demo-box">
|
|
5
6
7
|
{{ text }}
</div>
</ClickOutSide>
|
vben
authored
|
8
|
</PageWrapper>
|
|
9
10
11
|
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
|
vben
authored
|
12
|
import { ClickOutSide } from '/@/components/ClickOutSide';
|
vben
authored
|
13
14
|
import { PageWrapper } from '/@/components/Page';
|
|
15
|
export default defineComponent({
|
vben
authored
|
16
|
components: { ClickOutSide, PageWrapper },
|
|
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>
|
nebv
authored
|
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;
|
Vben
authored
|
38
|
background-color: #408ede;
|
nebv
authored
|
39
40
41
42
43
|
border-radius: 10px;
justify-content: center;
align-items: center;
}
</style>
|