index.vue 618 B

123456789101112131415161718192021222324252627282930
  1. <template>
  2. <app-statusbar class="app-navback" @click="goback">
  3. <slot>
  4. <Icon name="arrow-left" />
  5. </slot>
  6. </app-statusbar>
  7. </template>
  8. <script lang="ts" setup>
  9. import { useAttrs } from 'vue'
  10. import { useRouter } from 'vue-router'
  11. import { Icon } from 'vant'
  12. const emit = defineEmits<{ (event: string, ...args: unknown[]): void }>()
  13. const router = useRouter()
  14. const attrs = useAttrs()
  15. // 返回按钮事件
  16. const goback = () => {
  17. if (attrs.onBack) {
  18. emit('back')
  19. } else {
  20. router.go(-1)
  21. }
  22. }
  23. </script>
  24. <style lang="less">
  25. @import './index.less';
  26. </style>