docs_vue2/one/docs/demo/directives/outside/click.vue

53 lines
728 B
Vue
Raw Normal View History

2020-08-13 11:47:56 +08:00
<template>
<article
@mouseenter="inDemo = true"
@mouseleave="inDemo = false"
>
<div
v-outside="handleOutside"
class="box"
>
目标元素 A
</div>
</article>
</template>
<script>
2021-09-16 19:23:58 +08:00
import { outside, toast } from 'veui'
2020-08-13 11:47:56 +08:00
export default {
directives: {
outside
},
data () {
return {
timer: null,
inDemo: false
}
},
methods: {
handleOutside () {
if (this.inDemo) {
toast.info('点击了目标元素 A 外部。')
}
}
}
}
</script>
2021-09-15 20:03:51 +08:00
<style lang="less" scoped>
2020-08-13 11:47:56 +08:00
.box {
2021-09-15 20:03:51 +08:00
width: 500px;
height: 100px;
background: #f7f7f7;
2020-08-13 11:47:56 +08:00
display: flex;
align-items: center;
justify-content: center;
}
article {
margin: -30px;
padding: 30px;
}
</style>