index.vue 1.1 KB

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