import { defineComponent, reactive, onMounted } from 'vue' import Header from '@/components/Header' import { HttpConfig } from '@shared/config/index' import { UrlCheckUtils } from '@shared/utils' import { useCounterStore } from '@/stores/counter' import { storeToRefs } from 'pinia' interface stateType { list: ListItemType[] } interface ListItemType { id: number title: string } export default defineComponent({ name: "Home", setup() { const counterStore = useCounterStore() const { increment } = counterStore const { count, doubleCount } = storeToRefs(counterStore) const state = reactive({ list: [ { id: 1, title: '新闻1' }, { id: 2, title: '新闻2' }, { id: 3, title: '新闻3' }, ] }) onMounted(() => { // console.log("onMounted: ", HttpConfig.DevBaseUrl); console.log("check: ", UrlCheckUtils.check()) }) // 定义处理子组件事件的函数 const handleChildEvent = (message: string) => { console.log('收到子组件事件:', message) } return () => (
{ console.log("通过props自定义事件传给子组件"); }} onSendMessage={handleChildEvent}> {{ scoped: (item: ListItemType) =>
  • {item.title}
  • , header: () =>
    父到子 具名 插槽
    , default: () =>
    父到子 default 插槽
    }}

    首页

    点我+1:{count.value}
    ) } })