import { defineComponent, reactive, watch } from 'vue' import icon from './images/icon.png' import classes from './index.module.less' import detaile from './images/detaile.png' import music from './images/music.png' import arrow from './images/arrow.png' import { goodsType } from '@/constant' import { useRouter } from 'vue-router' type Props = { id?: number addName: string addUserAvatar: string musicSheetName: string subjectNames: string composer: string titleImg: string chargeType: string } const chargeTypes = { CHARGE: '点播', FREE: '免费', VIP: 'VIP' } export default defineComponent({ name: 'music-item', props: { item: { type: Object as () => Props, default: () => ({}) }, onClick: { type: Function, default: (item: any) => {} } }, setup(props: any) { const state = reactive({ item: props.item }) const router = useRouter() watch( () => props.item, item => { state.item = item } ) const gotoMusicDetail = () => { router.push({ path: '/muiscDetial', query: { id: state.item.id } }) } return () => (
{ props.onClick(state.item) }} >
gotoMusicDetail()}>

{state.item.musicSheetName}

{chargeTypes[state.item.chargeType] ? chargeTypes[state.item.chargeType] : '点播'}

作曲: {state.item.composer} {/* {state.item.addName ? state.item.addName : '小酷有谱'} */}
{state.item.subjectNames ? (
{state.item.subjectNames}
) : null}
) } })