vue 3字体中的道具



我有一个这样的组件,在propыHEADER中我传递字符串。

<template>
<div>
<section class="pb-5">
<job-filters-sidebar-checkbox-group
header="Job types"
:uniqueValues="uniqueJobTypes"
:mutation="ADD_SELECTED_JOB_TYPES"
/>
</section>
</div>
</template>

在子组件中,我接受道具并指定类型。但是typescript在子组件中的头上发誓。

<template>
<accordion :header="header">

</accordion>
</template>
<script lang="ts">
import Accordion from "@/components/Shared/Accordion.vue";
import { defineComponent, ref, PropType } from "@vue/runtime-core";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
export default defineComponent({
name: "JobFiltersSidebarChecbox",
components: {
Accordion,
},
props: {
header: {
type: String as PropType<string>,
require: true,
},
uniqueValues: {
type: Set as PropType<Set<string>>,
required: true,
},
mutation: {
type: String,
required: true,
},
},
setup(props) {...},
});
</script>

在头道具定义中更改为必需

最新更新