如何在 Vue.js 中将实例化的 Vue 组件作为道具传递?

时间:2021-06-24 09:23:13

标签: vue.js vue-component vue-props

我想将一个实例化的 Vue 组件作为 prop 传递给另一个组件,然后渲染它,如下所示:

<Button :icon=<IconComponent size="25" /> :link="http://wikipedia.org">Click here to visit Wikipedia</Button>

这至少是我在 React 中的做法。我怎样才能用 Vue 达到同样的效果?

1 个答案:

答案 0 :(得分:0)

您需要在子组件中使用命名插槽:

quarkus-oidc

在父组件中:

<template>
  <button>
    <slot name="icon"></slot>
    <slot></slot>
 </button>
</template>
相关问题