index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { Tab, Tabs } from 'vant'
  2. import { defineComponent, onMounted, ref } from 'vue'
  3. import AlbumList from '../album'
  4. import Practice from './practice'
  5. import Personal from './personal'
  6. import Collection from './collection'
  7. import Album from './album'
  8. import styles from './index.module.less'
  9. export default defineComponent({
  10. name: 'MusicPersonal',
  11. setup() {
  12. const activeTab = ref('personal')
  13. const personal = ref()
  14. const collection = ref()
  15. const practice = ref()
  16. return () => {
  17. return (
  18. <div class={styles.personal}>
  19. <Practice
  20. ref={practice}
  21. onFavorite={() => {
  22. if (activeTab.value === 'personal') {
  23. personal.value?.reset?.()
  24. } else if (activeTab.value === 'collection') {
  25. collection.value?.reset?.()
  26. }
  27. }}
  28. />
  29. <Tabs
  30. color="var(--van-primary)"
  31. background="transparent"
  32. lineWidth={20}
  33. shrink
  34. v-model:active={activeTab.value}
  35. onChange={val => (activeTab.value = val)}
  36. >
  37. <Tab title="我的单曲" name="personal"></Tab>
  38. <Tab title="收藏单曲" name="collection"></Tab>
  39. <Tab title="收藏专辑" name="album"></Tab>
  40. </Tabs>
  41. {activeTab.value === 'personal' && (
  42. <Personal
  43. ref={personal}
  44. onFavorite={() => {
  45. practice.value?.reload?.()
  46. }}
  47. />
  48. )}
  49. {activeTab.value === 'collection' && (
  50. <Collection
  51. ref={collection}
  52. onFavorite={() => {
  53. practice.value?.reload?.()
  54. }}
  55. />
  56. )}
  57. {activeTab.value === 'album' && <Album />}
  58. </div>
  59. )
  60. }
  61. }
  62. })