我想将一个实例化的 Vue 组件作为 prop 传递给另一个组件,然后渲染它,如下所示:
<Button :icon=<IconComponent size="25" /> :link="http://wikipedia.org">Click here to visit Wikipedia</Button>
这至少是我在 React 中的做法。我怎样才能用 Vue 达到同样的效果?
答案 0 :(得分:0)
您需要在子组件中使用命名插槽:
quarkus-oidc
在父组件中:
<template>
<button>
<slot name="icon"></slot>
<slot></slot>
</button>
</template>