是否可以在Vue中创建父(包装)组件?我看了看,却找不到任何东西
我想到的是以下内容(v-something组件来自vuetify库):
//cardWrapper.js
<template>
<v-card>
<v-row>
<v-col>
</v-col>
</v-row>
</v-card>
<template>
<script>
export default {
blabla
}
</script>
然后应该可以使用它,以便我可以在主文件中
// index.vue
<template>
<cardWrapper>
<v-btn>Click Me!</v-btn>
</cardWrapper>
</template>
我猜这是一个简单的过程,而且我只是没有正确地使用它。 我唯一能找到的就是使用动态组件,但我宁愿不将组件作为属性传递
答案 0 :(得分:0)
这是答案:
自定义组件
//custom-parent.vue
<template>
<custom-parent>
<slot/>
</custom-parent>
</template>
主文件
//index.vue
<template>
<custom-parent>
<a>Hellohello</a>
</custom-parent>
</template>