index.vue 831 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <view class="hc-nav-back-bar" :class="ui">
  3. <view class="back" @click="goToBack" v-if="isBack">
  4. <text un-i-material-symbols-chevron-left-rounded class="icon"/>
  5. <text class="text">返回</text>
  6. </view>
  7. <view class="title">{{titles}}</view>
  8. <view class="right">
  9. <slot/>
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. import {ref, watch} from "vue";
  15. const props = defineProps({
  16. ui: String,
  17. title: String,
  18. back: {
  19. type: Boolean,
  20. default: true,
  21. },
  22. });
  23. const isBack = ref(props.back)
  24. const titles = ref(props.title)
  25. //监听
  26. watch(() => [
  27. props.title,
  28. props.back,
  29. ], ([title, back]) => {
  30. titles.value = title
  31. isBack.value = back
  32. })
  33. //返回
  34. const goToBack = () => {
  35. uni.navigateBack()
  36. }
  37. </script>
  38. <style scoped lang="scss">
  39. @import "./style.scss";
  40. </style>