sanmu
authored
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<script setup lang="ts">
import { onMounted, watchEffect, toValue } from 'vue'
import { RouterLink, RouterView } from 'vue-router'
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import axios from 'axios'
import { useCategoryStore } from './stores/category'
import { useProductListStore } from './stores/product_list'
const categoryStore = useCategoryStore()
const productListStore = useProductListStore()
onMounted(() => {
// 请求分类列表
categoryStore.getList()
})
watchEffect(() => {
if (toValue(categoryStore?.list)) {
const cId = categoryStore?.list?.[0]?.list?.[0]?.id
if (cId) productListStore.updateCategory(cId)
}
})
</script>
<template>
<Header />
<div class="tw-min-h-[700px]">
|