src\components\DayPage\List\item.vue
<template>
<div class="list-item">
<div class="block title">{{title}}</div>
<div class="block content">{{content}}</div>
</div>
</template>
<script>
export default {
name: 'ListItem',
props: {
title: String,
content: String
}
}
</script>
src\components\DayPage\List\index.vue
<template>
<div class="day-list">
<list-item title="当前年月" :content="data['year-month']" />
<list-item title="今年属相" :content="data.animalsYear" />
<list-item title="农历年份" :content="data.lunarYear" />
<list-item title="宜" :content="data.suit" />
<list-item title="忌" :content="data.avoid" />
</div>
</template>
<script>
import ListItem from "./item";
export default {
name: "DayList",
props: {
data: Object,
},
components: {
ListItem,
},
};
</script>
src\views\Day.vue
首页
<template>
<div class="container">
<day-card :data='dayData'></day-card>
<day-list :data='dayData'></day-list>
</div>
</template>
<script>
import getData from '@/services'
import { getNowDate } from '@/libs/utils'
import { computed, onMounted } from 'vue'
import { useStore } from 'vuex'
import DayCard from '@/components/DayPage/Card'
import DayList from '@/components/DayPage/List'
export default {
name: 'DayPage',
components: { DayCard,DayList },
setup() {
const store = useStore(),
state = store.state
onMounted(() => {
// getData(store, 'day', getNowDate('day'))
})
return {
dayData: computed(()=> state.dayData)
}
},
}
</script>