js_reverse/学习VUE/hello_vue3/笔记/defineProps接收数据并页面展示子.vue
2024-10-31 17:55:51 +08:00

35 lines
667 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="person">
<h2>{{ a }}</h2>
<h2>{{ list }}</h2>
<ul>
<li v-for="item in list" :key="item.id">
{{ item.name }} -- {{ item.age }} -- {{ item.id }}
</li>
</ul>
</div>
</template>
<script setup lang="ts">
import {defineProps, withDefaults} from 'vue'
import {type Persons} from '@/types'
// 接收a并且将a保存起来. 接收list
const props = defineProps<{
a: string; // 假设 a 是字符串类型
list: Persons; // list 的类型为 Persons 自定义类型
}>()
</script>
<style scoped>
.person {
background-color: antiquewhite;
box-shadow: 0 0 10px;
}
button {
margin: 5px;
}
</style>