TopBar.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <main>
  3. <div v-for="(item, key) in list" :key="key" @click="chooseNav(key)">
  4. <img :src="item.icon" />
  5. </div>
  6. </main>
  7. </template>
  8. <script>
  9. import { defineComponent, ref } from 'vue'
  10. export default defineComponent({
  11. components: {
  12. },
  13. props: ['index'],
  14. setup(props, {emit}) {
  15. const list = ref([
  16. {
  17. icon: new URL('@/assets/icons/riLine-wechat-line.svg',import.meta.url).href,
  18. type: 'wechat'
  19. },
  20. {
  21. icon: new URL('@/assets/icons/riLine-qr-code-line.svg',import.meta.url).href,
  22. title: 'qr',
  23. },
  24. {
  25. icon: new URL('@/assets/icons/riLine-time-line.svg',import.meta.url).href,
  26. title: 'record',
  27. }
  28. ]);
  29. const chooseNav = (index) => {
  30. emit('choose-nav', index);
  31. };
  32. return {
  33. list,
  34. chooseNav
  35. }
  36. }
  37. })
  38. </script>
  39. <style scoped>
  40. main {
  41. display: flex;
  42. >div {
  43. width: 24px;
  44. height: 24px;
  45. margin-right: 16px;
  46. display: flex;
  47. align-items: center;
  48. justify-content: center;
  49. cursor: pointer;
  50. border-radius: 4px;
  51. &:hover {
  52. background: rgba(229, 229, 229, 1);
  53. }
  54. }
  55. }
  56. </style>